Merge pull request #66 from esc-chula/fix/build-error #5
This file contains hidden or 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: Build API Image | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| env: | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Gather tags name | |
| env: | |
| IMAGE_NAME: ${{ env.IMAGE_NAME }} | |
| SHA: ${{ github.sha }} | |
| REF: ${{ github.ref }} | |
| id: tags | |
| run: | | |
| RESULT="$IMAGE_NAME:latest,$IMAGE_NAME:$SHA" | |
| case "$REF" in | |
| refs/tags/v*) | |
| RESULT="${RESULT},$IMAGE_NAME:${REF#refs/tags/v}" | |
| ;; | |
| esac | |
| echo "tags = $RESULT" | |
| echo "tags=$RESULT" >> "$GITHUB_OUTPUT" | |
| - name: Build Docker image | |
| run: docker build . -t ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.tags }} -f ./apps/api/Dockerfile | |
| - name: Push Docker image to GitHub Container Registry | |
| run: docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.tags }} |