Skip to content

Commit

Permalink
ci: use github registry instead of dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed Jul 26, 2024
1 parent cd6162e commit a45c744
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
63 changes: 45 additions & 18 deletions .github/workflows/handle_llvm_runner_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea

0 comments on commit a45c744

Please sign in to comment.