Skip to content

DAT-19181 GitHub Actions Error: uploading S3 Object to Bucket #240

DAT-19181 GitHub Actions Error: uploading S3 Object to Bucket

DAT-19181 GitHub Actions Error: uploading S3 Object to Bucket #240

# Terraform Action to lint and apply updated redirects
name: Publish Redirects to Staging for Docs
on:
push:
branches:
- master
paths:
- 'scripts/redirect_creation/**'
pull_request:
branches:
- master
paths:
- 'scripts/redirect_creation/**'
jobs:
publish-docs-staging-redirects:
runs-on: ubuntu-20.04
permissions: write-all
env:
TF_VAR_env: "staging"
SPACELIFT_API_KEY_ENDPOINT: ${{ secrets.SPACELIFT_API_KEY_ENDPOINT }}
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
defaults:
run:
working-directory: scripts/redirect_creation
steps:
- name: Checkout branch with draft redirects
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Install spacectl
uses: spacelift-io/setup-spacectl@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ADMIN_GITHUB_OIDC_ROLE_ARN_DOCS }}
aws-region: us-east-1
- name: Check website redirects format
run: |
if grep -P 'website_redirect\s*=\s*"[^/]' variables.tf; then
echo "Error: Found website_redirect that doesn't start with '/'"
echo "All website_redirect values must start with a forward slash"
echo "Example: website_redirect = \"/home.html\""
exit 1
fi
- name: Terraform Format
if: ${{ github.event_name == 'pull_request' }}
id: fmt
run: terraform fmt
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
if: ${{ github.event_name == 'pull_request' }}
id: validate
run: terraform validate -no-color
- name: Preview infrastructure
run: |
spacectl stack local-preview --id liquibase-docs-staging > ${GITHUB_WORKSPACE}/plan.out
cat ${GITHUB_WORKSPACE}/plan.out
- name: Terraform Show Plan in PR
uses: actions/github-script@v7
continue-on-error: true
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const run_url = process.env.GITHUB_SERVER_URL + '/' + process.env.GITHUB_REPOSITORY + '/actions/runs/' + process.env.GITHUB_RUN_ID
const run_link = '<a href="' + run_url + '">Actions</a>.'
const fs = require('fs')
const plan_file = fs.readFileSync('plan.out', 'utf8')
const plan = plan_file.length > 65000 ? plan_file.toString().substring(0, 65000) + " ..." : plan_file
const truncated_message = plan_file.length > 65000 ? "Output is too long and was truncated. You can read full Plan in " + run_link + "<br /><br />" : ""
const output = `#### Terraform Format and Style πŸ–Œ\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization βš™οΈ\`${{ steps.init.outcome }}\`
#### Terraform Validation πŸ€–\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
#### Terraform Plan πŸ“–\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${plan}
\`\`\`
</details>
${truncated_message}
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ github.workspace }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Deploy infrastructure
if: ${{ github.event_name == 'push' }}
run: |
spacectl stack set-current-commit --id liquibase-docs-staging --sha ${{ github.sha }}
spacectl stack deploy --id liquibase-docs-staging --auto-confirm