Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start testing ECR authentication. #1237

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/ecr-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: ECR Authentication test

on:
pull_request_target:
branches: [ 'main' ]

permissions:
# This let's us clone the repo
contents: read
# This let's us mint identity tokens.
id-token: write

jobs:
krane:
runs-on: ubuntu-latest
env:
AWS_ACCOUNT: 479305788615
AWS_REGION: us-east-2

steps:
- name: Set up Go 1.17.x
uses: actions/setup-go@v2
with:
go-version: 1.17.x

- name: Check out code
uses: actions/checkout@v2

- name: Install krane
working-directory: ./cmd/krane
run: go install .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have caught this: aws-actions/configure-aws-credentials@v1.6.0 here and below. Dependabot should help us keep it up to date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT }}:role/federated-ecr-readonly
aws-region: ${{ env.AWS_REGION }}

- name: Test krane + ECR
run: |
# List the tags
krane ls ${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/go-containerregistry-test
crane-ecr-login:
runs-on: ubuntu-latest
env:
AWS_ACCOUNT: 479305788615
AWS_REGION: us-east-2

steps:
- name: Set up Go 1.17.x
uses: actions/setup-go@v2
with:
go-version: 1.17.x

- name: Check out code
uses: actions/checkout@v2

- name: Install crane
working-directory: ./cmd/crane
run: go install .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT }}:role/federated-ecr-readonly
aws-region: ${{ env.AWS_REGION }}

- run: |
wget https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/0.5.0/linux-amd64/docker-credential-ecr-login
chmod +x ./docker-credential-ecr-login
mv docker-credential-ecr-login /usr/local/bin
cat > $HOME/.docker/config.json <<EOF
{
"credHelpers": {
"${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com": "ecr-login"
}
}
EOF
- name: Test crane + ECR
run: |
# List the tags
crane ls ${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/go-containerregistry-test