Skip to content

Commit

Permalink
ci: refactor zk env workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
otani88 committed Oct 2, 2023
1 parent 38d66b1 commit 86af830
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 55 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: CI

on:
pull_request:
paths-ignore:
- "docker/zk-environment/Dockerfile"
- ".github/workflows/zk-environment.publish.yml"
- "docker/zk-environment-cuda-12-0/Dockerfile"
- ".github/workflows/zk-environment-cuda-12-0.publish.yml"
- "docker/zk-rust-nightly-environment/Dockerfile"
- ".github/workflows/rust-nightly-environment.publish.yml"
merge_group:
push:
branches:
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/zk-environment-cuda-12-0.publish.yml

This file was deleted.

108 changes: 103 additions & 5 deletions .github/workflows/zk-environment.publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish zk-environment docker image
name: publish zk-environment docker images

on:
pull_request:
Expand All @@ -8,15 +8,47 @@ on:
paths:
- "docker/zk-environment/Dockerfile"
- ".github/workflows/zk-environment.publish.yml"
- "docker/zk-environment-cuda-12-0/Dockerfile"
- ".github/workflows/zk-environment-cuda-12-0.publish.yml"
- "docker/zk-rust-nightly-environment/Dockerfile"
- ".github/workflows/rust-nightly-environment.publish.yml"
workflow_dispatch:
branches:
- "main"

jobs:
push_to_registry:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
name: Push Docker image to Docker Hub
runs-on: [matterlabs-ci-runner]
changed_files:
name: Changed files
outputs:
zk_environment: ${{ steps.changed-files-yaml.outputs.zk_env_any_changed }}
zk_environment_cuda_12: ${{ steps.changed-files-yaml.outputs.zk_env_cuda_12_any_changed }}
rust_nightly: ${{ steps.changed-files-yaml.outputs.rust_nightly_any_changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: Get changed files
id: changed-files-yaml
uses: tj-actions/changed-files@v39
with:
files_yaml: |
zk_env:
- docker/zk-environment/Dockerfile
- .github/workflows/zk-environment.publish.yml
zk_env_cuda_12:
- docker/zk-environment-cuda-12-0/Dockerfile
- .github/workflows/zk-environment-cuda-12-0.publish.yml
rust_nightly:
- docker/zk-rust-nightly-environment/Dockerfile
- .github/workflows/rust-nightly-environment.publish.yml
zk_environment:
if: needs.changed_files.outputs.zk_environment == 'true' && github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
name: Push zk-environment docker image to Docker Hub
runs-on: ubuntu-latest
needs: changed_files
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
Expand Down Expand Up @@ -51,3 +83,69 @@ jobs:
tags: "matterlabs/zk-environment:latest2.0"
file: docker/zk-environment/Dockerfile
no-cache: true

rust_nightly:
if: needs.changed_files.outputs.rust_nightly == 'true' && github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
name: Push rust nightly docker image to Docker Hub
needs: changed_files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # v2

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
context: .
push: true
tags: "matterlabs/zksync_rust:nightly"
file: docker/zk-rust-nightly-environment/Dockerfile
no-cache: true


zk_environment_cuda_12:
if: needs.changed_files.outputs.zk_environment_cuda_12 == 'true' github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
name: Push zk-environment cuda 12 docker image to Docker Hub
runs-on: [matterlabs-ci-runner]
needs: changed_files
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: "recursive"

- name: Login to us-central1 GAR
run: |
gcloud auth print-access-token --lifetime=7200 --impersonate-service-account=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/zk-environment-cuda-12-0/Dockerfile
push: true
target: nvidia-tools
tags: |
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zk-environment-cuda-12-0:latest
matterlabs/zk-environment:cuda-12-0-latest

0 comments on commit 86af830

Please sign in to comment.