Skip to content

Commit 6ceae0a

Browse files
authored
Merge pull request #159 from w3c/deploy-pr
add action to deploy assets from PR and delete them when the PR is closed
2 parents 263ee98 + 8e9af62 commit 6ceae0a

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.github/workflows/deploy-pr.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
pull_request:
3+
types: [opened, edited, reopened, synchronize]
4+
5+
jobs:
6+
build_css:
7+
runs-on: ubuntu-latest
8+
env:
9+
source: public/dist/assets
10+
destination: assets/website-2021-dev/pr-${{ github.event.number }}/
11+
steps:
12+
- name: Checkout source Git branch
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{github.event.pull_request.head.ref}}
16+
persist-credentials: false
17+
18+
- name: Use Node.js
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: '16'
22+
23+
- name: Install npm modules
24+
run: npm install
25+
26+
- name: compile assets
27+
run: npm run build
28+
29+
- name: Upload to cdn-dev.w3.org bucket
30+
if: success()
31+
env:
32+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
33+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34+
AWS_REGION: 'us-east-1'
35+
run:
36+
aws s3 sync --no-progress ${{ env.source }} s3://cdn-dev.w3.org/${{ env.destination }}

.github/workflows/pr-closed.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
pull_request:
3+
types:
4+
- closed
5+
6+
jobs:
7+
delete_assets:
8+
runs-on: ubuntu-latest
9+
env:
10+
destination: assets/website-2021-dev/pr-${{ github.event.number }}/
11+
steps:
12+
- name: Delete PR assets from the cdn-dev.w3.org bucket
13+
if: success()
14+
env:
15+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
16+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
17+
AWS_REGION: 'us-east-1'
18+
run:
19+
aws s3 rm --recursive s3://cdn-dev.w3.org/${{ env.destination }}

0 commit comments

Comments
 (0)