fix!: Bump AWS provider #38
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: pre-commit & tests | |
env: | |
AWS_REGION: af-south-1 | |
AWS_ROLE_ARN: arn:aws:iam::353444730604:role/cat-genrl-prd-infra-github-workflows | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
- master | |
- develop | |
concurrency: | |
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre | |
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write | |
contents: read | |
defaults: | |
# Set shell for steps inside containers (default=sh) | |
run: | |
shell: bash | |
jobs: | |
#-------------------------------------------------------------- | |
# PRE-COMMIT | |
#-------------------------------------------------------------- | |
pre_commit: | |
name: 💍 pre-commit | |
# For public repos use runs-on: ubuntu-latest | |
# For private repos use runs-on: self-hosted | |
runs-on: ubuntu-latest | |
container: bjorncloudandthings/terraform-aws-github:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- uses: hashicorp/setup-terraform@v2 | |
- name: Install requirements | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
pip install pre-commit checkov | |
- name: Configure ~/.terraformrc | |
run: | | |
cat <<-EOF >> ~/.terraformrc | |
credentials "app.terraform.io" { | |
token = "${{ secrets.TERRAFORM_CLOUD_TOKEN }}" | |
} | |
EOF | |
- name: pre-commit run | |
run: | | |
source .venv/bin/activate | |
if [[ "${{ env.GITHUB_REPOSITORY}}" == "cloudandthings/terraform-aws-template" ]]; then | |
export SKIP=no-vanilla-readme | |
fi | |
echo ...running pre-commit checks... | |
pre-commit run --config .pre-commit-config.yaml --all-files --show-diff-on-failure | |
- name: cat pre-commit log | |
if: failure() | |
run: | | |
LOG_FILE=~/.cache/pre-commit/pre-commit.log | |
if [ -f "$LOG_FILE" ]; then | |
cat $LOG_FILE | |
fi | |
#-------------------------------------------------------------- | |
# TESTS | |
#-------------------------------------------------------------- | |
tests: | |
needs: [pre_commit] | |
name: ✅ tests | |
# For public repos use runs-on: ubuntu-latest | |
# For private repos use runs-on: self-hosted | |
runs-on: ubuntu-latest | |
container: bjorncloudandthings/terraform-aws-github:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- uses: hashicorp/setup-terraform@v2 | |
- uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
role-to-assume: ${{ env.AWS_ROLE_ARN }} | |
role-duration-seconds: 3600 | |
- name: Install requirements | |
run: | | |
python -m venv .venv | |
source .venv/bin/activate | |
pip install -r tests/requirements.txt | |
- name: Run | |
run: | | |
source .venv/bin/activate | |
echo "::echo::off" | |
pytest | |
env: | |
PYTEST_ADDOPTS: "--color=yes" | |
timeout-minutes: 15 |