--omit=dev #11
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
| # build.yml | |
| name: Build & Push Docker Image to GHCR | |
| on: | |
| push: # Triggers the workflow on push events | |
| branches: | |
| - main | |
| workflow_dispatch: # Allows manual triggering of the workflow from the GitHub Actions tab | |
| env: | |
| DOCKERFILE_PATH: ./server/Dockerfile # π Update this to wherever your Dockerfile is within your repository | |
| jobs: | |
| build-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository π | |
| uses: actions/checkout@v4 # Clones the repo for the workflow to access | |
| - name: Set up QEMU for cross-platform builds | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry π | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Convert owner and repo to lowercase | |
| id: vars | |
| run: | | |
| echo "repo_owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" | |
| echo "repo_name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" | |
| # Builds and pushes the Docker image to GitHub Container Registry | |
| # Uses the latest tag and the commit SHA as a version tag | |
| - name: Build and Push Multi-Arch Image π | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE_PATH }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ steps.vars.outputs.repo_owner }}/${{ steps.vars.outputs.repo_name }}:latest | |
| ghcr.io/${{ steps.vars.outputs.repo_owner }}/${{ steps.vars.outputs.repo_name }}:${{ github.sha }} |