name: Build and Push Docker Image on: workflow_dispatch: push: branches: - master env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }}/backend jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout code uses: actions/checkout@v4 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=sha,format=short type=ref,event=branch - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: ./frontend file: ./frontend/Dockerfile push: true # Always push the normal tags; if this is a master push, # prepend "latest" to the list. tags: ${{ github.ref == 'refs/heads/master' && format('{0},latest', steps.meta.outputs.tags) || steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}