ci #6
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: ci | |
on: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
BASE_IMAGE_NAME: ${{ github.repository }}-base | |
IMAGE_NAME: ${{ github.repository }} | |
ENABLE_ARTIFACT_ATTESTATION: ${{ vars.ENABLE_ARTIFACT_ATTESTATION || 'false' }} | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Base RabbitMQ Docker image | |
id: meta-base | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }} | |
- name: Build and push Base RabbitMQ Docker image | |
id: push-base | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta-base.outputs.tags }} | |
labels: ${{ steps.meta-base.outputs.labels }} | |
# only available for paid plans | |
- name: Generate artifact attestation for Base RabbitMQ Docker image | |
if: ${{ env.ENABLE_ARTIFACT_ATTESTATION == 'true' }} | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME}} | |
subject-digest: ${{ steps.push-base.outputs.digest }} | |
push-to-registry: true | |
- name: Extract metadata (tags, labels) for RabbitMQ Docker image | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push RabbitMQ Docker image | |
id: push | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
BASE_IMAGE_TAG=${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME}}:main | |
context: . | |
file: Dockerfile.dev | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# only available for paid plans | |
- name: Generate artifact attestation for RabbitMQ Docker image | |
if: ${{ env.ENABLE_ARTIFACT_ATTESTATION == 'true' }} | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |