|
| 1 | +name: Publish CloudFormation Template |
| 2 | + |
| 3 | +# Publishes deploy/aws/cloudformation.yaml to a public S3 URL so the README's |
| 4 | +# "Launch Stack" button (CloudFormation Quick Create) has a template to load. |
| 5 | +# Quick Create only accepts an S3-hosted templateURL, not a raw GitHub URL. |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - 'deploy/aws/cloudformation.yaml' |
| 12 | + - '.github/workflows/publish-template.yml' |
| 13 | + release: |
| 14 | + types: [published] |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + id-token: write |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: publish-template |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +env: |
| 26 | + AWS_REGION: us-east-1 |
| 27 | + # The bucket and key the README button points at. The bucket must exist, have |
| 28 | + # a policy granting public s3:GetObject on the aws/* prefix, and the role |
| 29 | + # below must be allowed to PutObject into it. See deploy/aws/README.md. |
| 30 | + TEMPLATE_BUCKET: textile-stitch-deploy |
| 31 | + TEMPLATE_KEY: aws/cloudformation.yaml |
| 32 | + |
| 33 | +jobs: |
| 34 | + publish: |
| 35 | + runs-on: ubuntu-22.04 |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v6 |
| 38 | + with: |
| 39 | + persist-credentials: false |
| 40 | + |
| 41 | + - name: Configure AWS credentials |
| 42 | + uses: aws-actions/configure-aws-credentials@v4 |
| 43 | + with: |
| 44 | + role-to-assume: ${{ secrets.AWS_TEMPLATE_PUBLISH_ROLE }} |
| 45 | + aws-region: ${{ env.AWS_REGION }} |
| 46 | + |
| 47 | + - name: Validate template |
| 48 | + run: | |
| 49 | + aws cloudformation validate-template \ |
| 50 | + --template-body file://deploy/aws/cloudformation.yaml |
| 51 | +
|
| 52 | + - name: Publish template to S3 |
| 53 | + run: | |
| 54 | + # Immutable per-commit copy operators can pin, plus the stable key the |
| 55 | + # README's one-click button loads. |
| 56 | + aws s3 cp deploy/aws/cloudformation.yaml \ |
| 57 | + "s3://${TEMPLATE_BUCKET}/aws/cloudformation-${GITHUB_SHA}.yaml" \ |
| 58 | + --content-type text/yaml |
| 59 | + aws s3 cp deploy/aws/cloudformation.yaml \ |
| 60 | + "s3://${TEMPLATE_BUCKET}/${TEMPLATE_KEY}" \ |
| 61 | + --content-type text/yaml |
0 commit comments