diff --git a/.github/actions/update-internal-mirrors/action.yaml b/.github/actions/update-internal-mirrors/action.yaml new file mode 100644 index 000000000..1a38e4e04 --- /dev/null +++ b/.github/actions/update-internal-mirrors/action.yaml @@ -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 diff --git a/scripts/mirror.json b/.github/actions/update-internal-mirrors/scripts/mirror.json similarity index 100% rename from scripts/mirror.json rename to .github/actions/update-internal-mirrors/scripts/mirror.json diff --git a/scripts/update_mirrors.sh b/.github/actions/update-internal-mirrors/scripts/update_mirrors.sh similarity index 100% rename from scripts/update_mirrors.sh rename to .github/actions/update-internal-mirrors/scripts/update_mirrors.sh diff --git a/.github/workflows/update-internal-mirrors.yaml b/.github/workflows/update-internal-mirrors.yaml index 9f441bc42..d3b3d6513 100644 --- a/.github/workflows/update-internal-mirrors.yaml +++ b/.github/workflows/update-internal-mirrors.yaml @@ -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 @@ -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 }}