Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move to github registry instead of dockerhub #81

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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