Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Next problem

Workflow

jobs:
  pr-tests:
    runs-on: gitops-prod-base
    steps:
      - name: "workaround for act #1112"
        uses: actions/checkout@v2
        if: "false"

      - name: Run tests against the PR
        uses: example-org/private-github-actions/actions/environment-sceptre/umbrella-pr-tests@master
        with:
          aws-role: ${{ secrets.AWS_IAM_ROLE_RO }}
          region: us-east-1
          token: ${{ secrets.FSA_GITHUBTOKEN }}

umbrella-pr-tests

---
name: 'Sceptre PR tests'

inputs:
  aws-role:
    description: 'The AWS account to role to switch to'
    required: true

  region:
    description: 'AWS region'
    required: false
    default: us-east-1

  sceptre-fx-image:
    description: 'sceptre-fx docker image'
    required: false
    default: 123456789012.dkr.ecr.us-east-1.amazonaws.com/example-org/example-project1:latest

  sceptre-fx-repo:
    description: 'sceptre-fx project repo'
    required: false
    default: example-org/example-project2

  token:
    description: 'Github token'
    required: true

runs:
  using: "composite"
  steps:
    - name: yaml-lint values files
      uses: example-org/private-github-actions/actions/yaml-lint@master
      with:
        token: ${{ inputs.token }}

    - name: Check sceptre values files for common errors
      uses: example-org/private-github-actions/actions/environment-sceptre/check-values-files@master
      with:
        token: ${{ inputs.token }}

    - name: sceptre-fx validate and diff
      uses: example-org/private-github-actions/actions/environment-sceptre/sceptre-fx-diff@master
      with:
        aws-role: ${{ inputs.aws-role }}
        region: ${{ inputs.region }}
        token: ${{ inputs.token }}

sceptre-fx-diff

---
name: 'Sceptre-fx diff'

inputs:
  artifactory-fqdn:
    description: 'FQDN of artifactory'
    required: false
    default: myartifactory

  aws-role:
    description: 'The AWS account to role to switch to'
    required: true

  helper-script:
    description: 'helper shell script to use'
    required: false
    default: sceptre-fx-helper.sh

  region:
    description: 'AWS region'
    required: false
    default: us-east-1

  sceptre-fx-image:
    description: 'sceptre-fx docker image'
    required: false
    default: 123456789012.dkr.ecr.us-east-1.amazonaws.com/example-org/example-project1:latest

  sceptre-fx-repo:
    description: 'sceptre-fx project repo'
    required: false
    default: example-org/example-project2

  token:
    description: 'Github token'
    required: true

runs:
  using: "composite"
  steps:
    - name: Checkout repo
      uses: actions/checkout@v2

    - name: Get list of changed files
      id: files
      uses: jitterbit/get-changed-files@v1

    - name: test AWS runner credentials
      shell: bash
      run: |
        # action: sceptre-fx-diff, step: test AWS runner credentials
        aws sts get-caller-identity
...

Running Act

▶ act -s AWS_IAM_ROLE_RO=$AWS_ROLE -s FSA_GITHUBTOKEN=ghp_xxxx -e pull-request.json -s GITHUB_TOKEN=ghp_xxxx -P gitops-prod-base=gha-default-runner:latest pull_request -j pr-tests 

[PR Check values files/pr-tests] ⭐  Run test AWS runner credentials
[PR Check values files/pr-tests]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1-composite-2-composite-2.sh] user= workdir=
| 
| Unable to locate credentials. You can configure credentials by running "aws configure".
[PR Check values files/pr-tests]   ❌  Failure - test AWS runner credentials
[PR Check values files/pr-tests] exit with `FAILURE`: 253
[PR Check values files/pr-tests]   ❌  Failure - sceptre-fx validate and diff
[PR Check values files/pr-tests] exit with `FAILURE`: 253
[PR Check values files/pr-tests]   ❌  Failure - Run tests against the PR
[PR Check values files/pr-tests] exit with `FAILURE`: 253
Error: Job 'pr-tests' failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment