Wowie what a gay little website for my gay little self aria.coffee
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #6 from BuyMyMojo/docker-auto-push

feat(Gh actions): Auto build and push docker builds to GH registry

authored by

Aria and committed by
GitHub
3fabac0b d2629485

+57 -3
+57 -3
.github/workflows/docker-image.yml
··· 3 3 on: 4 4 push: 5 5 branches: [ "main" ] 6 + # Publish semver tags as releases. 7 + tags: [ 'v*.*.*' ] 6 8 pull_request: 7 9 branches: [ "main" ] 8 10 11 + 12 + env: 13 + # Use docker.io for Docker Hub if empty 14 + REGISTRY: ghcr.io 15 + # github.repository as <account>/<repo> 16 + IMAGE_NAME: ${{ github.repository }} 17 + 9 18 jobs: 10 19 11 20 build: 12 21 13 22 runs-on: ubuntu-latest 23 + permissions: 24 + contents: read 25 + packages: write 26 + id-token: write 14 27 15 28 steps: 16 - - uses: actions/checkout@v4 17 - - name: Build the Docker image 18 - run: docker build . --file Dockerfile --tag aria-coffee:$(date +%s) 29 + - name: Checkout repository 30 + uses: actions/checkout@v4 31 + 32 + - name: Install cosign 33 + if: github.event_name != 'pull_request' 34 + uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0 35 + with: 36 + cosign-release: 'v1.11.0' 37 + 38 + - name: Setup Docker buildx 39 + uses: docker/setup-buildx-action@v3 40 + 41 + - name: Log into registry ${{ env.REGISTRY }} 42 + if: github.event_name != 'pull_request' 43 + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 44 + with: 45 + registry: ${{ env.REGISTRY }} 46 + username: ${{ github.actor }} 47 + password: ${{ secrets.GITHUB_TOKEN }} 48 + 49 + - name: Extract Docker metadata 50 + id: meta 51 + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 52 + with: 53 + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 54 + 55 + - name: Build and push Docker image 56 + id: build-and-push 57 + uses: docker/build-push-action@v6 58 + with: 59 + context: "{{defaultContext}}:src" 60 + push: ${{ github.event_name != 'pull_request' }} # Don't push on PR 61 + tags: ${{ steps.meta.outputs.tags }} 62 + labels: ${{ steps.meta.outputs.labels }} 63 + cache-from: type=gha 64 + cache-to: type=gha,mode=max 65 + 66 + - name: Sign the image with cosign 67 + if: github.event_name != 'pull_request' 68 + run: | 69 + cosign sign --key cosign.key ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}: 70 + 71 + # - name: Build the Docker image 72 + # run: docker build . --file Dockerfile --tag aria-coffee:$(date +%s)