π Sync docs with S3 #27
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π Sync docs with S3 | |
on: workflow_dispatch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: docs | |
fetch-depth: 0 | |
- name: π‘οΈ Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: π¦ Install dependencies | |
run: npm ci | |
- name: β‘ Generate docs metadata | |
run: npm run generate:metadata | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_OWNER: ${{ github.repository_owner }} | |
GITHUB_REPO: ${{ github.event.repository.name}} | |
- name: π Check for changes | |
id: git-check | |
run: | | |
if [ -z "$(git diff HEAD^ HEAD -- posts/)" ]; then | |
echo "No changes detected." | |
echo "{changes}={false}" >> $GITHUB_ENV | |
else | |
echo "Changes detected." | |
echo "{changes}={true}" >> $GITHUB_ENV | |
fi | |
- name: πͺ£ Sync to S3 | |
if: env.changes == 'true' | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks --delete | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'eu-north-1' | |
SOURCE_DIR: 'posts' | |
DEST_DIR: 'posts' | |
changes: ${{ github.env.changes }} |