-
-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (45 loc) · 1.46 KB
/
sync-s3-posts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: 🔁 Sync docs with S3
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: 🛡️ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 📦 Install dependencies
run: npm ci
- name: 🌳 Extract Repository Name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)" >> $GITHUB_ENV
- name: ⚡ Generate docs metadata
run: npm run generate:metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: $REPO_NAME
- name: 🏁 Check for changes
id: git-check
run: |
if git diff HEAD^ HEAD -- posts/; then
echo "No changes detected."
echo "::set-output name=changes::false"
else
echo "Changes detected."
echo "::set-output name=changes::true"
fi
- name: 🪣 Sync to S3
if: steps.git-check.outputs.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'