Merge pull request #9 from bill-of-materials/renovate/pin-dependencies #13
This file contains 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 | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GHCR_IMAGE_NAME: ${{ github.repository }} | |
DOCKERHUB_IMAGE_NAME: ${{ vars.DOCKERHUB_IMAGE_NAME }} | |
jobs: | |
docker_build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
strategy: | |
matrix: | |
architecture: [linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@a64d0487d7069df33b279515d35d60fa80e2ea62 | |
with: | |
images: | | |
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }} | |
ghcr.io/${{ env.GHCR_IMAGE_NAME }} | |
tags: | | |
type=sha | |
labels: | | |
org.opencontainers.image.title=${{ env.GHCR_IMAGE_NAME }} | |
org.opencontainers.image.description="tg2 IRIG-B or WWV timecode generator" | |
org.opencontainers.image.vendor="${{ github.repository_owner }}" | |
org.opencontainers.image.url="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.source="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.version="0.0.1" | |
org.opencontainers.image.created="${{ github.event.head_commit.timestamp }}" | |
org.opencontainers.image.revision="${{ github.sha }}" | |
org.opencontainers.image.licenses="MIT" | |
annotations: | | |
org.opencontainers.image.title=${{ env.GHCR_IMAGE_NAME }} | |
org.opencontainers.image.description="tg2 IRIG-B or WWV timecode generator" | |
org.opencontainers.image.vendor="${{ github.repository_owner }}" | |
org.opencontainers.image.url="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.source="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.version="0.0.1" | |
org.opencontainers.image.created="${{ github.event.head_commit.timestamp }}" | |
org.opencontainers.image.revision="${{ github.sha }}" | |
org.opencontainers.image.licenses="MIT" | |
- name: Build Docker image | |
id: build | |
uses: docker/build-push-action@e050dfa622d93dfcc095192a984db567cb14f0f0 | |
with: | |
context: . | |
push: false | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: ${{ matrix.architecture }} | |
outputs: type=registry | |
create_multi_platform_manifest_and_push: | |
runs-on: ubuntu-latest | |
needs: docker_build | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create and push multi-platform manifest | |
id: push | |
run: | | |
docker buildx imagetools create \ | |
--tag docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }} \ | |
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v6 \ | |
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/amd64 \ | |
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm64 \ | |
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v7 | |
docker buildx imagetools create \ | |
--tag ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }} \ | |
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v6 \ | |
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/amd64 \ | |
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm64 \ | |
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v7 | |
- name: Generate artifact attestation (ghcr) | |
id: push-ghcr | |
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1 | |
with: | |
subject-name: ghcr.io/${{ env.GHCR_IMAGE_NAME }} | |
subject-digest: ${{ needs.docker_build_and_push.outputs.digest }} | |
push-to-registry: true | |
- name: Generate artifact attestation (dockerhub) | |
id: push-dockerhub | |
uses: actions/attest-build-provenance@5e9cb68e95676991667494a6a4e59b8a2f13e1d0 # v1 | |
with: | |
subject-name: index.docker.io/${{ env.DOCKERHUB_IMAGE_NAME }} | |
subject-digest: ${{ needs.docker_build_and_push.outputs.digest }} | |
push-to-registry: true |