|
86 | 86 | # Use tags / labels provided by 'docker/metadata-action' above |
87 | 87 | tags: ${{ steps.meta_build.outputs.tags }} |
88 | 88 | labels: ${{ steps.meta_build.outputs.labels }} |
| 89 | + alpine-build: |
| 90 | + # Ensure this job never runs on forked repos. It's only executed for 'jerm/snipe-it' |
| 91 | + if: github.repository == 'grokability/jerm-it' |
| 92 | + runs-on: ubuntu-latest |
| 93 | + env: |
| 94 | + # Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action) |
| 95 | + # For a new commit on default branch (master), use the literal tag 'latest' on Docker image. |
| 96 | + # For a new commit on other branches, use the branch name as the tag for Docker image. |
| 97 | + # For a new tag, copy that tag name as the tag for Docker image. |
| 98 | + IMAGE_TAGS: | |
| 99 | + type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},suffix=-alpine |
| 100 | + type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }},suffix=-alpine |
| 101 | + type=ref,event=tag,suffix=-alpine |
| 102 | + type=semver,pattern=v{{major}}-latest-alpine |
| 103 | + # Define default tag "flavor" for docker/metadata-action per |
| 104 | + # https://github.com/docker/metadata-action#flavor-input |
| 105 | + # We turn off 'latest' tag by default. |
| 106 | + TAGS_FLAVOR: | |
| 107 | + latest=false |
| 108 | +
|
| 109 | + steps: |
| 110 | + # https://github.com/actions/checkout |
| 111 | + - name: Checkout codebase |
| 112 | + uses: actions/checkout@v4 |
| 113 | + |
| 114 | + # https://github.com/docker/setup-buildx-action |
| 115 | + - name: Setup Docker Buildx |
| 116 | + uses: docker/setup-buildx-action@v3 |
| 117 | + |
| 118 | + # https://github.com/docker/login-action |
| 119 | + - name: Login to DockerHub |
| 120 | + # Only login if not a PR, as PRs only trigger a Docker build and not a push |
| 121 | + if: github.event_name != 'pull_request' |
| 122 | + uses: docker/login-action@v3 |
| 123 | + with: |
| 124 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 125 | + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} |
| 126 | + |
| 127 | + ############################################### |
| 128 | + # Build/Push the 'jermgroks/jerm-it' image |
| 129 | + ############################################### |
| 130 | + # https://github.com/docker/metadata-action |
| 131 | + # Get Metadata for docker_build step below |
| 132 | + - name: Sync metadata (tags, labels) from GitHub to Docker for 'jerm-it' image |
| 133 | + id: meta_build |
| 134 | + uses: docker/metadata-action@v5 |
| 135 | + with: |
| 136 | + images: jermgroks/jerm-it |
| 137 | + tags: ${{ env.IMAGE_TAGS }} |
| 138 | + flavor: ${{ env.TAGS_FLAVOR }} |
| 139 | + |
| 140 | + # https://github.com/docker/build-push-action |
| 141 | + - name: Build and push 'jerm-it' image |
| 142 | + id: docker_build |
| 143 | + uses: docker/build-push-action@v6 |
| 144 | + with: |
| 145 | + context: . |
| 146 | + file: ./Dockerfile.alpine |
| 147 | + platforms: linux/arm64 |
| 148 | + # For pull requests, we run the Docker build (to ensure no PR changes break the build), |
| 149 | + # but we ONLY do an image push to DockerHub if it's NOT a PR |
| 150 | + push: ${{ github.event_name != 'pull_request' }} |
| 151 | + # Use tags / labels provided by 'docker/metadata-action' above |
| 152 | + tags: ${{ steps.meta_build.outputs.tags }} |
| 153 | + labels: ${{ steps.meta_build.outputs.labels }} |
0 commit comments