From a45c7445fcb2c6d200daa79ae2d294d8ecce4520 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Fri, 26 Jul 2024 15:54:51 +0100 Subject: [PATCH] ci: use github registry instead of dockerhub --- .../workflows/handle_llvm_runner_image.yml | 63 +++++++++++++------ .gitignore | 1 + 2 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/handle_llvm_runner_image.yml b/.github/workflows/handle_llvm_runner_image.yml index 1a5a560..719bd88 100644 --- a/.github/workflows/handle_llvm_runner_image.yml +++ b/.github/workflows/handle_llvm_runner_image.yml @@ -8,43 +8,70 @@ on: branches: - main +env: + REGISTRY: ghcr.io + WORKSPACE: matter-labs + IMAGE_NAME: llvm_runner + jobs: handle_image: runs-on: matterlabs-default-infra-runners + + permissions: + contents: read + packages: write + attestations: write + id-token: write + strategy: + # Keep matrix for future purposes + # now, we need only the latest version matrix: - tag_prefix: ["ubuntu20-llvm17", "ubuntu22-llvm15", "ubuntu22-llvm17"] + image_version: [ "ubuntu22-llvm17" ] fail-fast: false steps: - - uses: actions/checkout@v4 + + - name: Checkout + uses: actions/checkout@v4 - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: images/llvm_runner/${{ matrix.tag_prefix }}.Dockerfile + dockerfile: images/${{ env.IMAGE_NAME }}/${{ matrix.image_version }}.Dockerfile ignore: DL4006 - - name: Identify short SHA - id: short_sha - run: echo "sha=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}" - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - platforms: 'linux/amd64,linux/arm64,linux/arm64/v8' + platforms: 'linux/amd64,linux/arm64' - - name: Log in to Docker Hub - if: github.event_name == 'push' + - name: Log in to the Container registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and optionally push Docker image + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.WORKSPACE }}/${{ env.IMAGE_NAME }}/${{ matrix.image_version }} + flavor: latest=true + + - name: Build and push Docker image + id: push uses: docker/build-push-action@v5 with: push: ${{ github.event_name == 'push' }} - tags: | - matterlabs/llvm_runner:${{ matrix.tag_prefix }}-${{ steps.short_sha.outputs.sha }} - matterlabs/llvm_runner:${{ matrix.tag_prefix }}-latest - file: images/llvm_runner/${{ matrix.tag_prefix }}.Dockerfile - platforms: 'linux/amd64,linux/arm64,linux/arm64/v8' + file: images/${{ env.IMAGE_NAME }}/${{ matrix.image_version }}.Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: 'linux/amd64,linux/arm64' + + - name: Generate artifact attestation + if: github.event_name == 'push' + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.WORKSPACE }}/${{ env.IMAGE_NAME }}/${{ matrix.image_version }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea