feat: Add structured logging for GCP #279
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "CI/CD: Continuous integration and continuous deployment" | |
"on": | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
pull_request: | |
env: | |
IMAGE_NAME: "tvvlmj/${{ github.event.repository.name }}" | |
TEST_STAGE: tester | |
PRODUCTION_STAGE: production | |
jobs: | |
build-check-test-push: | |
name: Build, check, test, push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
cache: "npm" | |
- name: Install NPM dependencies | |
run: npm ci | |
# This step considers also the files ignored in .dockerignore, such as | |
# documentation and GitHub Actions workflows. | |
- name: Check and test outside Docker | |
run: npm run check-and-build | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
tags: | | |
type=edge,branch=main | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
type=sha,format=long | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
target: "${{ env.TEST_STAGE }}" | |
tags: "${{ env.IMAGE_NAME }}:${{ env.TEST_STAGE }}" | |
# This step runs the tests in an environment that closely resembles the | |
# production Docker image. | |
- name: Check and test inside Docker | |
run: | | |
docker run --rm "${{ env.IMAGE_NAME }}:${{ env.TEST_STAGE }}" | |
- name: Login to Docker Hub | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
target: "${{ env.PRODUCTION_STAGE }}" | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |