Repository navigation
Build Docker Image #17
Workflow file for this run
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 Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| paths-ignore: | |
| - README.md | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Image version without the v prefix" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| GHCR_REPO: ghcr.io/${{ github.repository }} | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Resolve version | |
| id: version | |
| shell: bash | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| run: | | |
| if [[ -n "${INPUT_VERSION}" ]]; then | |
| version="${INPUT_VERSION#v}" | |
| elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| version="${GITHUB_REF_NAME#v}" | |
| else | |
| version="${GITHUB_SHA::12}" | |
| fi | |
| echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
| echo "tag=v${version}" >> "${GITHUB_OUTPUT}" | |
| echo "sha_short=${GITHUB_SHA::12}" >> "${GITHUB_OUTPUT}" | |
| - name: Set up QEMU | |
| 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.repository_owner }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Build and push to GHCR | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| push: true | |
| provenance: false | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| tags: | | |
| ${{ env.GHCR_REPO }}:latest | |
| ${{ env.GHCR_REPO }}:${{ steps.version.outputs.version }} | |
| ${{ env.GHCR_REPO }}:${{ steps.version.outputs.tag }} | |
| ${{ env.GHCR_REPO }}:${{ steps.version.outputs.sha_short }} | |
| cache-from: type=gha,scope=${{ github.ref_name }} | |
| cache-to: type=gha,mode=max,scope=${{ github.ref_name }} |