|
| 1 | +name: Publish Adapter Images to Public ECR |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - public-adapter-versions.yml |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + # For this workflow, build-all will cause all adapters to have their image pulled and republished to the public ECR |
| 12 | + # NOTE: If the images haven't been already published to the private ECR, this will fail; in that case run the deploy workflow first. |
| 13 | + build-all: |
| 14 | + description: whether to run steps for all adapters, regardless of whether they were changed in this event |
| 15 | + required: false |
| 16 | + default: 'false' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: deploy-and-release |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + calculate-changes: |
| 24 | + name: Compute changed adapters |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + runs-on: [ubuntu-latest] |
| 28 | + env: |
| 29 | + BUILD_ALL: ${{ inputs.build-all }} |
| 30 | + outputs: |
| 31 | + adapter-list: ${{ steps.changed-adapters.outputs.CHANGED_ADAPTERS }} |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v5 |
| 34 | + with: |
| 35 | + persist-credentials: false |
| 36 | + fetch-depth: 2 |
| 37 | + - name: Set up and install dependencies |
| 38 | + uses: ./.github/actions/setup |
| 39 | + with: |
| 40 | + skip-setup: true |
| 41 | + - name: Build list of changed packages and changed adapters |
| 42 | + id: changed-adapters |
| 43 | + env: |
| 44 | + UPSTREAM_BRANCH: HEAD~1 |
| 45 | + run: | |
| 46 | + echo "CHANGED_ADAPTERS=$(./.github/scripts/list-changed-public-adapters.sh)" >> $GITHUB_OUTPUT |
| 47 | +
|
| 48 | + create-ecr: |
| 49 | + name: Create ECR for ${{ matrix.adapter.shortName }} |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: [calculate-changes] |
| 52 | + if: needs.calculate-changes.outputs.adapter-list != '[]' |
| 53 | + permissions: # These are needed for the configure-aws-credentials action |
| 54 | + id-token: write |
| 55 | + contents: read |
| 56 | + environment: release |
| 57 | + strategy: |
| 58 | + max-parallel: 20 |
| 59 | + matrix: ${{fromJson(needs.calculate-changes.outputs.adapter-list)}} |
| 60 | + env: |
| 61 | + ECR_URL: public.ecr.aws/chainlink |
| 62 | + ECR_REPO: adapters/${{ matrix.adapter.shortName }}-adapter |
| 63 | + IMAGE_VERSION: ${{ matrix.adapter.version }} |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v5 |
| 66 | + with: |
| 67 | + persist-credentials: false |
| 68 | + - name: Create ECR for ${{ matrix.adapter.shortName }} |
| 69 | + uses: ./.github/actions/create-ecrs |
| 70 | + with: |
| 71 | + aws-ecr-url: ${{ env.ECR_URL }} |
| 72 | + aws-ecr-repo: ${{ env.ECR_REPO }} |
| 73 | + aws-region: us-east-1 |
| 74 | + aws-role: ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }} |
| 75 | + aws-ecr-private: false |
| 76 | + |
| 77 | + publish-adapter-images: |
| 78 | + name: Fetch and publish ${{ matrix.adapter.shortName }} |
| 79 | + runs-on: ubuntu-latest |
| 80 | + needs: |
| 81 | + - calculate-changes |
| 82 | + environment: release |
| 83 | + permissions: # These are needed for the configure-aws-credentials action |
| 84 | + id-token: write |
| 85 | + contents: read |
| 86 | + strategy: |
| 87 | + max-parallel: 20 |
| 88 | + matrix: ${{fromJson(needs.calculate-changes.outputs.adapter-list)}} |
| 89 | + env: |
| 90 | + PUBLIC_ECR_URL: public.ecr.aws/chainlink |
| 91 | + PRIVATE_ECR_URL: ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com |
| 92 | + ECR_REPO: adapters/${{ matrix.adapter.shortName }}-adapter |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v5 |
| 95 | + with: |
| 96 | + persist-credentials: false |
| 97 | + - name: Configure AWS Credentials |
| 98 | + uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0 |
| 99 | + with: |
| 100 | + role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }} |
| 101 | + aws-region: ${{ secrets.AWS_REGION_ECR_PRIVATE }} |
| 102 | + mask-aws-account-id: true |
| 103 | + - name: Copy images with attestations from private to public ECR |
| 104 | + env: |
| 105 | + AWS_REGION: ${{ secrets.AWS_REGION_ECR_PRIVATE }} |
| 106 | + SOURCE_IMAGE: ${{ env.PRIVATE_ECR_URL }}/${{ env.ECR_REPO }}:${{ matrix.adapter.version }} |
| 107 | + DEST_IMAGE: ${{ env.PUBLIC_ECR_URL }}/${{ env.ECR_REPO }}:${{ matrix.adapter.version }} |
| 108 | + run: | |
| 109 | + PRIVATE_ECR_PASSWORD=$(aws ecr get-login-password --region "${AWS_REGION}") |
| 110 | + echo "::add-mask::${PRIVATE_ECR_PASSWORD}" |
| 111 | + PUBLIC_ECR_PASSWORD=$(aws ecr-public get-login-password --region us-east-1) |
| 112 | + echo "::add-mask::${PUBLIC_ECR_PASSWORD}" |
| 113 | +
|
| 114 | + # Copy all architectures, attestations (SBOM, provenance), and signatures |
| 115 | + echo "Copying versioned image: ${SOURCE_IMAGE} -> ${DEST_IMAGE}" |
| 116 | + skopeo copy \ |
| 117 | + --all \ |
| 118 | + --preserve-digests \ |
| 119 | + --retry-times 3 \ |
| 120 | + --src-creds AWS:${PRIVATE_ECR_PASSWORD} \ |
| 121 | + --dest-creds AWS:${PUBLIC_ECR_PASSWORD} \ |
| 122 | + docker://${SOURCE_IMAGE} \ |
| 123 | + docker://${DEST_IMAGE} |
0 commit comments