-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci)!: implement reusable workflows for image building (#4173)
* refactor(ci): test building in a separate workflow * force a change * force a change * fix(ci): send the correct variables to the reusable build * fix(ci): variables are not allowed * fix(ci): conditions are not allowed as input * fix(ci): use expected value * refactor(build): simplify the use of other dockerfiles * fix(cd): depend on docker build yml * fix(cd): use main branch as image name * imp(actions): remove uneeded variable repetition * imp(build): remove unused variables * imp(actions): rename the image building workflow Not all images are for zebra execution as we also have one for zcash-params * fix(ci): add dependable workflow in paths filters * docs(ci): remove TODO as this won't be needed at least an issue arises * docs(ci): CARGO_INCREMENTAL can decrease build time when running from a cache * fix: revert forced changes * fix(build): remove unused build inputs in zcash-params * imp(cd): as this is the production image, use the executable name * imp(ci): reduce log level to improve speed Co-authored-by: teor <teor@riseup.net> * imp(ci): use the correct name for the workflow Co-authored-by: teor <teor@riseup.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: teor <teor@riseup.net>
- Loading branch information
1 parent
597f553
commit 83d2689
Showing
7 changed files
with
179 additions
and
385 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: Build docker image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
network: | ||
required: false | ||
type: string | ||
checkpoint_sync: | ||
required: false | ||
type: boolean | ||
image_name: | ||
required: true | ||
type: string | ||
dockerfile_path: | ||
required: true | ||
type: string | ||
dockerfile_target: | ||
required: true | ||
type: string | ||
short_sha: | ||
required: false | ||
type: string | ||
rust_backtrace: | ||
required: false | ||
type: string | ||
rust_lib_backtrace: | ||
required: false | ||
type: string | ||
colorbt_show_hidden: | ||
required: false | ||
type: string | ||
zebra_skip_ipv6_tests: | ||
required: false | ||
type: string | ||
rust_log: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
build: | ||
name: Build images | ||
timeout-minutes: 210 | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
steps: | ||
- uses: actions/checkout@v3.0.2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
with: | ||
short-length: 7 | ||
|
||
# Automatic tag management and OCI Image Format Specification for labels | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3.7.0 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }} | ||
gcr.io/zealous-zebra/zcashfoundation-zebra/${{ inputs.image_name }} | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
# Setup Docker Buildx to allow use of docker cache layers from GH | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Authenticate to Google Cloud | ||
id: auth | ||
uses: google-github-actions/auth@v0.7.1 | ||
with: | ||
workload_identity_provider: 'projects/143793276228/locations/global/workloadIdentityPools/github-actions/providers/github-oidc' | ||
service_account: 'github-service-account@zealous-zebra.iam.gserviceaccount.com' | ||
token_format: 'access_token' | ||
|
||
- name: Login to Google Artifact Registry | ||
uses: docker/login-action@v1.14.1 | ||
with: | ||
registry: us-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: ${{ steps.auth.outputs.access_token }} | ||
|
||
- name: Login to Google Container Registry | ||
uses: docker/login-action@v1.14.1 | ||
with: | ||
registry: gcr.io | ||
username: oauth2accesstoken | ||
password: ${{ steps.auth.outputs.access_token }} | ||
|
||
# Build and push image to Google Artifact Registry | ||
- name: Build & push | ||
id: docker_build | ||
uses: docker/build-push-action@v2.10.0 | ||
with: | ||
target: ${{ inputs.dockerfile_target }} | ||
context: . | ||
file: ${{ inputs.dockerfile_path }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
NETWORK=${{ inputs.network }} | ||
SHORT_SHA=${{ env.GITHUB_SHA_SHORT }} | ||
RUST_BACKTRACE=${{ inputs.rust_backtrace }} | ||
RUST_LIB_BACKTRACE=${{ inputs.rust_lib_backtrace }} | ||
COLORBT_SHOW_HIDDEN=${{ inputs.colorbt_show_hidden }} | ||
ZEBRA_SKIP_IPV6_TESTS=${{ inputs.zebra_skip_ipv6_tests }} | ||
CHECKPOINT_SYNC=${{ inputs.checkpoint_sync }} | ||
RUST_LOG=${{ inputs.rust_log }} | ||
push: true | ||
cache-from: type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-buildcache | ||
cache-to: type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-buildcache,mode=max |
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
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
Oops, something went wrong.