Skip to content

Merge pull request #437 from cloudnativedaysjp/seaman/release_1785860… #123

Merge pull request #437 from cloudnativedaysjp/seaman/release_1785860…

Merge pull request #437 from cloudnativedaysjp/seaman/release_1785860… #123

Workflow file for this run

name: Deploy Website to S3
on:
push:
tags:
- v*
# Notionボタン等の外部トリガーからのリビルド用(最新のv*タグをビルドする)
repository_dispatch:
types: [rebuild-website]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: deploy-website
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Resolve ref to build
id: resolve
run: |
if [ "${GITHUB_EVENT_NAME}" = "repository_dispatch" ]; then
# 外部トリガー時はデフォルトブランチではなく最新のリリースタグをビルドする
ref=$(git ls-remote --tags "https://github.com/${GITHUB_REPOSITORY}.git" 'refs/tags/v*' \
| awk '{print $2}' | grep -v '\^{}$' | sed 's|^refs/tags/||' | sort -V | tail -n 1)
if [ -z "${ref}" ]; then
echo "No v* tag found" >&2
exit 1
fi
else
ref="${GITHUB_REF_NAME}"
fi
echo "Building ref: ${ref}"
echo "ref=${ref}" >> "${GITHUB_OUTPUT}"
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: ${{ steps.resolve.outputs.ref }}
persist-credentials: false
- uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6.2.0
with:
aws-region: 'ap-northeast-1'
role-to-assume: 'arn:aws:iam::607167088920:role/github-actions'
- name: Install, build, and upload your site
uses: withastro/action@b7d53628f8b666036b0238aadb0b984a2a489f26 # v6.1.1
env:
NOTION_API_SECRET: ${{ secrets.NOTION_API_SECRET }}
DATABASE_ID: ${{ secrets.DATABASE_ID }}
- name: Deploy to S3
run: aws s3 sync ./dist/ s3://${{ secrets.BUCKET_ID }}
- name: Create CloudFront invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*"