Utils cleanup (#235) #2980
This file contains hidden or 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
# TON Relayer Docker Publishing Workflow | ||
# Builds and publishes Docker images for the TON relayer, | ||
# including the base Chainlink core image and the combined core+relayer image | ||
name: TON - Relayer - Publish Docker Image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v*" | ||
pull_request: | ||
types: [labeled, opened, synchronize, reopened] | ||
jobs: | ||
# Identifies which Chainlink core image to use as the base for building the TON relayer. | ||
# It handles both SHA refs and tag refs differently. | ||
determine-core-image: | ||
name: Determine Chainlink Core Base Image | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
outputs: | ||
base_image: ${{ steps.detect-core-image.outputs.BASE_IMAGE }} | ||
base_image_tag: ${{ steps.detect-core-image.outputs.BASE_IMAGE_TAG }} | ||
base_image_public: ${{ steps.detect-core-image.outputs.BASE_IMAGE_PUBLIC }} | ||
base_image_already_exists: ${{ steps.detect-core-image.outputs.EXISTS }} | ||
core_ref: ${{ steps.detect-core-image.outputs.CORE_REF }} | ||
core_ref_short: ${{ steps.detect-core-image.outputs.CORE_REF_SHORT }} | ||
steps: | ||
# Setup and Authentication | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 | ||
with: | ||
aws-region: ${{ vars.AWS_REGION }} | ||
role-to-assume: ${{ secrets.AWS_ROLE_PUBLISH_ARN_STAGING }} | ||
role-duration-seconds: 3600 | ||
mask-aws-account-id: true | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 | ||
with: | ||
mask-password: "true" | ||
registries: "${{ secrets.AWS_ACCOUNT_ID_STAGING}}" | ||
- name: Checkout Repository | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
# Core Image Detection Script | ||
- name: Detect and Configure Core Image | ||
id: detect-core-image | ||
env: | ||
AWS_ACCOUNT_ID_STAGING: ${{ secrets.AWS_ACCOUNT_ID_STAGING }} | ||
AWS_REGION: ${{ vars.AWS_REGION }} | ||
run: ./.github/scripts/detect-core-image.sh | ||
# Only runs if the core image doesn't already exist | ||
build-core-image: | ||
name: Build & Publish Chainlink Core Docker Image | ||
needs: determine-core-image | ||
if: | | ||
needs.determine-core-image.outputs.base_image_already_exists != 'true' && ( | ||
github.event_name != 'pull_request' || | ||
contains(github.event.pull_request.labels.*.name, 'build-publish-docker') | ||
) | ||
permissions: | ||
contents: read | ||
id-token: write | ||
uses: smartcontractkit/.github/.github/workflows/reusable-docker-build-publish.yml@b9f1725282972837f22590e820dea4ea891c779b | ||
Check failure on line 76 in .github/workflows/relayer-publish.yml
|
||
with: | ||
aws-ecr-name: chainlink-plugins-dev | ||
aws-region-ecr: ${{ vars.AWS_REGION }} | ||
aws-region-gati: ${{ vars.AWS_REGION }} | ||
dockerfile: core/chainlink.Dockerfile | ||
docker-build-context: . | ||
docker-build-args: | | ||
CHAINLINK_USER=chainlink | ||
COMMIT_SHA=${{ needs.determine-core-image.outputs.core_ref }} | ||
docker-manifest-sign: false | ||
docker-image-tag-override: ${{ needs.determine-core-image.outputs.base_image_tag }} | ||
git-sha: ${{ needs.determine-core-image.outputs.core_ref }} | ||
github-event-name: ${{ github.event_name }} | ||
github-ref-name: ${{ github.ref_name }} | ||
github-ref-type: ${{ github.ref_type }} | ||
github-workflow-repository: smartcontractkit/chainlink | ||
secrets: | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_STAGING }} | ||
AWS_ROLE_PUBLISH_ARN: ${{ secrets.AWS_ROLE_PUBLISH_ARN_STAGING }} | ||
AWS_ROLE_GATI_ARN: ${{ secrets.AWS_ROLE_ARN_GATI_READONLY }} | ||
AWS_LAMBDA_GATI_URL: ${{ secrets.AWS_LAMBDA_URL_GATI }} | ||
# Builds the final image combining Chainlink core with the TON relayer | ||
build-relayer-image: | ||
name: Build & Publish Chainlink Core + TON Relayer Image | ||
needs: [determine-core-image, build-core-image] | ||
if: | | ||
always() && | ||
needs.determine-core-image.result == 'success' && ( | ||
needs.build-core-image.result == 'success' || | ||
needs.build-core-image.result == 'skipped' | ||
) && ( | ||
github.event_name != 'pull_request' || | ||
contains(github.event.pull_request.labels.*.name, 'build-publish-docker') | ||
) | ||
permissions: | ||
contents: read | ||
id-token: write | ||
uses: smartcontractkit/.github/.github/workflows/reusable-docker-build-publish.yml@b9f1725282972837f22590e820dea4ea891c779b | ||
with: | ||
aws-ecr-name: chainlink-plugins-dev | ||
aws-region-ecr: ${{ vars.AWS_REGION }} | ||
aws-region-gati: ${{ vars.AWS_REGION }} | ||
dockerfile: scripts/build/Dockerfile.build.nix | ||
docker-build-context: . | ||
docker-manifest-sign: true | ||
docker-tag-custom-suffix: "-chainlink-ton" | ||
git-sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | ||
github-event-name: ${{ github.event_name }} | ||
github-ref-name: ${{ github.ref_name }} | ||
github-ref-type: ${{ github.ref_type }} | ||
github-workflow-repository: ${{ github.repository }} | ||
secrets: | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_STAGING }} | ||
AWS_ROLE_PUBLISH_ARN: ${{ secrets.AWS_ROLE_PUBLISH_ARN_STAGING }} | ||
AWS_ROLE_GATI_ARN: ${{ secrets.AWS_ROLE_ARN_GATI_READONLY }} | ||
AWS_LAMBDA_GATI_URL: ${{ secrets.AWS_LAMBDA_URL_GATI }} | ||
DOCKER_BUILD_ARGS: | | ||
CHAINLINK_USER=chainlink | ||
COMMIT_SHA=${{ github.sha }} | ||
BASE_IMAGE=${{ | ||
needs.determine-core-image.outputs.base_image_public == 'true' && | ||
needs.determine-core-image.outputs.base_image || | ||
format('{0}.dkr.ecr.{1}.amazonaws.com/chainlink-plugins-dev:{2}', | ||
secrets.AWS_ACCOUNT_ID_STAGING, | ||
vars.AWS_REGION, | ||
needs.determine-core-image.outputs.base_image_tag) | ||
}} | ||
# Updates the Kubernetes infrastructure with the newly built image | ||
deploy-to-staging: | ||
name: Update Staging Infrastructure | ||
needs: [build-relayer-image] | ||
if: always() && needs.build-relayer-image.result == 'success' | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Setup GitHub Token for Infrastructure Updates | ||
id: setup-github-token | ||
uses: smartcontractkit/.github/actions/setup-github-token@setup-github-token/1.0.0 | ||
with: | ||
aws-role-arn: ${{ secrets.AWS_ROLE_ARN_GATI_CHAINLINK_TON_CD }} | ||
aws-lambda-url: ${{ secrets.AWS_LAMBDA_URL_GATI_CHANGESETS }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
aws-role-duration-seconds: "1800" | ||
- name: Trigger Infrastructure Deployment | ||
env: | ||
GH_TOKEN: ${{ steps.setup-github-token.outputs.access-token }} | ||
# Deployment configuration | ||
WORKFLOW_FILE: image-bump-cd.yaml | ||
TARGET_REPO: ${{ secrets.REPO_K8S_DEPLOY }} | ||
TARGET_BRANCH: main | ||
IMAGE_TAG: ${{ needs.build-relayer-image.outputs.docker-manifest-tag }} | ||
# PR configuration for staging deployment | ||
PR_BASE_BRANCH: main | ||
PR_LABELS: preview-stage | ||
PR_DRAFT: "true" | ||
PRODUCTS: ccip-ton-staging | ||
run: | | ||
gh workflow run "${WORKFLOW_FILE}" \ | ||
--repo "${TARGET_REPO}" \ | ||
--ref "${TARGET_BRANCH}" \ | ||
--field "oci-image-tag=${IMAGE_TAG}" \ | ||
--field "pr-base-branch=${PR_BASE_BRANCH}" \ | ||
--field "pr-labels=${PR_LABELS}" \ | ||
--field "pr-draft=${PR_DRAFT}" \ | ||
--field "products=${PRODUCTS}" |