Skip to content

Commit

Permalink
TT-1138 Add Update Internal Mirrors Github Action (#968)
Browse files Browse the repository at this point in the history
* Add reusable update-internal-mirrors action

* fix

* fix 2

* Fix

* Reuse action in workflow

* Fix

* Bump

* Fix

* bump version in workflow

* Fix

* Fix name

* Remove old update mirrors scripts

The scripts were moved to update-internal-mirrors action

* Fix lint

* fix lint 2
  • Loading branch information
lukaszcl authored May 28, 2024
1 parent 6df0418 commit 7eb04a0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 55 deletions.
50 changes: 50 additions & 0 deletions .github/actions/update-internal-mirrors/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Update Internal Mirrors Action'
inputs:
aws_region:
description: 'AWS region for the ECR'
required: false
role_to_assume:
description: 'AWS IAM role to assume'
required: false
aws_account_number:
description: 'AWS Account Number'
required: false
image_name:
description: 'Name of the docker image to update'
required: false
expression:
description: 'Regex expression for image tags'
required: false
page_size:
description: 'Number of tags to return per page'
required: false
default: '100'
runs:
using: 'composite'
steps:
- name: Checkout the Repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-region: ${{ inputs.aws_region }}
role-to-assume: ${{ inputs.role_to_assume }}
role-duration-seconds: 3600
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
mask-password: 'true'
env:
AWS_REGION: ${{ inputs.aws_region }}
- name: Update images
shell: bash
run: |
# Update images
# Change to the directory where the action is stored
cd ${{ github.action_path }}
if [[ -z "${{ inputs.image_name }}" ]]; then
./scripts/update_mirrors.sh ${{ inputs.aws_account_number }}.dkr.ecr.${{ inputs.aws_region }}.amazonaws.com
else
# Update ${{ inputs.image_name }}
./scripts/update_mirrors.sh ${{ inputs.aws_account_number }}.dkr.ecr.${{ inputs.aws_region }}.amazonaws.com ${{ inputs.image_name }} '${{ inputs.expression }}' ${{ inputs.page_size }}
fi
File renamed without changes.
File renamed without changes.
68 changes: 13 additions & 55 deletions .github/workflows/update-internal-mirrors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,15 @@ jobs:
id-token: write
contents: read
steps:
- name: Checkout the Repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

# Setup AWS creds
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-region: ${{ secrets.QA_AWS_REGION }}
role-to-assume: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600

# Login to ECR
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Update image
uses: smartcontractkit/chainlink-testing-framework/.github/actions/update-internal-mirrors@9190fa16db15bbb7caa5595b347c51acdda9eb3a
with:
mask-password: 'true'
env:
AWS_REGION: ${{ secrets.QA_AWS_REGION }}

# - name: Login to Google Cloud
# uses: google-github-actions/auth@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
# with:
# credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'

# Update all mirror images
- name: Update images
id: check
shell: bash
run: |
./scripts/update_mirrors.sh ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com ${{matrix.mirror.name}} '${{matrix.mirror.expression}}' ${{matrix.mirror.page_size}}
aws_region: ${{ secrets.QA_AWS_REGION }}
role_to_assume: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
aws_account_number: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
image_name: ${{matrix.mirror.name}}
expression: ${{matrix.mirror.expression}}
page_size: ${{matrix.mirror.page_size}}

update-other-images:
runs-on: ubuntu-latest
Expand All @@ -97,29 +75,9 @@ jobs:
id-token: write
contents: read
steps:
- name: Checkout the Repo
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

# Setup AWS creds
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-region: ${{ secrets.QA_AWS_REGION }}
role-to-assume: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600

# Login to ECR
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Update other images
uses: smartcontractkit/chainlink-testing-framework/.github/actions/update-internal-mirrors@9190fa16db15bbb7caa5595b347c51acdda9eb3a
with:
mask-password: 'true'
env:
AWS_REGION: ${{ secrets.QA_AWS_REGION }}

# Update all mirror images
- name: Update images
id: check
shell: bash
run: |
./scripts/update_mirrors.sh ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com
aws_region: ${{ secrets.QA_AWS_REGION }}
role_to_assume: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
aws_account_number: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}

0 comments on commit 7eb04a0

Please sign in to comment.