workflow add #1
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 and Push Docker Image | |
| # Builds docker/Dockerfile on every push to main and publishes two tags to GHCR: | |
| # - :latest always points at the newest commit on main | |
| # - :alpha-v0.1.<N> a unique, ever-increasing build number (N = GitHub run number) | |
| # No release process — this project has no contributors/issues yet, so every commit | |
| # on main is just pushed straight to the registry. | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # GHCR requires lowercase image names; github.repository preserves repo casing | |
| # ("jherforth/Monastery"), which would fail the push. | |
| - name: Compute lowercase image name | |
| id: image | |
| run: echo "name=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:latest | |
| ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:alpha-v0.1.${{ github.run_number }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |