Skip to content

Migrate to Stackctl #321

Migrate to Stackctl

Migrate to Stackctl #321

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: main
permissions:
id-token: write
contents: read
pull-request: write

Check failure on line 11 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 11, Col: 3): Unexpected value 'pull-request'
env:
LOG_COLOR: always
STACKCTL_DIRECTORY: cg-app
STACKCTL_VERSION: 1.6.0.0
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install cfn-lint
- run: cfn-lint
changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
yamls:
- '${{ env.STACKCTL_DIRECTORY }}/stacks/**/*.yaml'
- '${{ env.STACKCTL_DIRECTORY }}/templates/**/*.json'
- '${{ env.STACKCTL_DIRECTORY }}/templates/**/*.yaml'
list-files: csv
# Make the paths relative to STACKCTL_DIRECTORY
- id: format
run: |
{
echo 'files<<EOF'
sed 's%${{ env.STACKCTL_DIRECTORY }}/%%g' <<'EOM'
${{ steps.filter.outputs.yamls_files }}
EOM
echo 'EOF'
} >> "$GITHUB_OUTPUT"
outputs:
files: ${{ steps.format.outputs.files }}
comment-changes:
if: ${{ github.ref != 'refs/heads/main' }}
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pbrisbin/setup-tool-action@v2
with:
name: stackctl
version: ${{ env.STACKCTL_VERSION }}
url: "https://github.com/freckle/{name}/releases/download/v{version}/{name}-{arch}-{os}.{ext}"
arch: x86_64
os-darwin: osx
subdir: "{name}"
- run: echo 'STACKCTL_FILTER=${{ needs.changes.outputs.files }}' >>"$GITHUB_ENV"
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- if: ${{ needs.changes.outputs.files != '' }}
run: stackctl changes --format pr /tmp/changes.md
- id: prep
run: |
tmp=$(mktemp)
echo "message-path=$tmp" >>"$GITHUB_OUTPUT"
find /tmp/changes -name 'changes.md' -exec cat {} + | tee "$tmp"
if [[ ! -s "$tmp" ]]; then
echo 'No Stack changes produced by this PR' | tee "$tmp"
fi
- uses: mshick/add-pr-comment@v2
with:
message-path: ${{ steps.prep.outputs.message-path }}
refresh-message-position: "true"
deploy-changes:
if: ${{ github.ref == 'refs/heads/main' }}
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pbrisbin/setup-tool-action@v2
with:
name: stackctl
version: ${{ env.STACKCTL_VERSION }}
url: "https://github.com/freckle/{name}/releases/download/v{version}/{name}-{arch}-{os}.{ext}"
arch: x86_64
os-darwin: osx
subdir: "{name}"
- run: echo 'STACKCTL_FILTER=${{ needs.changes.outputs.files }}' >>"$GITHUB_ENV"
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- if: ${{ needs.changes.outputs.files != '' }}
run: stackctl deploy --save-change-sets /tmp/changes --no-confirm --clean