Last active
February 3, 2021 14:13
-
-
Save voodoodror/cfe8c05e6f73ecea893581b1eb7a2a21 to your computer and use it in GitHub Desktop.
GitHub Actions Self-Hosted Runner with AWS credentials (EKS roles confirmed)
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: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: self-hosted | |
env: | |
REQUIRED_STATUS_CHECK: "true" | |
GITHUB_SHA_COMMIT: ${{ github.event.pull_request.head.sha }} | |
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" | |
container: | |
image: python:3.9 | |
env: | |
AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/token | |
AWS_ROLE_ARN: arn:aws:iam::884661243007:role/X/test-use1-example-runner-deployment | |
volumes: | |
- /var/run/secrets/eks.amazonaws.com/serviceaccount/token:/var/run/secrets/eks.amazonaws.com/serviceaccount/token | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Checkout master | |
uses: actions/checkout@v2 | |
with: | |
ref: 'master' | |
clean: false | |
- uses: webfactory/ssh-agent@v0.4.1 | |
with: | |
ssh-private-key: ${{ secrets.INFRA_MODULES_DEPLOY_KEY }} | |
- name: aws cli | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip && echo 'zip extraction completed' | |
chmod +x ./aws/install | |
./aws/install | |
- run: aws sts get-caller-identity | |
- run: git config user.name "GitHub Actions" | |
- run: git config user.email "actions@users.noreply.github.com" | |
- name: Add local bin path | |
run: | | |
echo $GITHUB_WORKSPACE >> $GITHUB_PATH | |
- name: Download Terragrunt | |
run: | | |
terragrunt_version=v0.23.33 | |
wget -O terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/${terragrunt_version}/terragrunt_linux_amd64 | |
chmod +x terragrunt | |
# Terraform must be >=0.13 | |
- name: Download Terraform | |
run: | | |
terraform_version=0.12.26 | |
wget -O terraform.zip https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_amd64.zip && unzip terraform.zip | |
chmod +x terraform | |
- name: Get Versions | |
run: | | |
terragrunt --version | |
terraform --version | |
- name: Execute Python script | |
run: | | |
python .github/cicd.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment