Running GitHub Actions on an AWS ECR image
This file contains 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
name: Run tests | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
ecr_login: | |
runs-on: ubuntu-latest | |
outputs: | |
ecr_password: ${{ steps.retrieve_password.outputs.ecr_password }} | |
steps: | |
- name: Set up AWS CLI | |
uses: chrislennon/action-aws-cli@1.1 | |
- id: retrieve_password | |
name: Retrieve ECR password and store as secret | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: us-west-2 | |
run: echo "::set-output name=ecr_password::$(aws ecr get-login-password)" | |
test: | |
needs: ecr_login | |
runs-on: ubuntu-latest | |
container: | |
image: ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/IMAGE:TAG | |
credentials: | |
username: AWS | |
password: ${{ needs.ecr_login.outputs.ecr_password }} | |
steps: | |
- run: echo "Running my tests inside a container pulled from ECR \o/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment