Skip to content

Commit

Permalink
Merge pull request #159 from w3c/deploy-pr
Browse files Browse the repository at this point in the history
add action to deploy assets from PR and delete them when the PR is closed
  • Loading branch information
deniak authored Jan 9, 2025
2 parents 263ee98 + 8e9af62 commit 6ceae0a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
build_css:
runs-on: ubuntu-latest
env:
source: public/dist/assets
destination: assets/website-2021-dev/pr-${{ github.event.number }}/
steps:
- name: Checkout source Git branch
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install npm modules
run: npm install

- name: compile assets
run: npm run build

- name: Upload to cdn-dev.w3.org bucket
if: success()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
run:
aws s3 sync --no-progress ${{ env.source }} s3://cdn-dev.w3.org/${{ env.destination }}
19 changes: 19 additions & 0 deletions .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
pull_request:
types:
- closed

jobs:
delete_assets:
runs-on: ubuntu-latest
env:
destination: assets/website-2021-dev/pr-${{ github.event.number }}/
steps:
- name: Delete PR assets from the cdn-dev.w3.org bucket
if: success()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
run:
aws s3 rm --recursive s3://cdn-dev.w3.org/${{ env.destination }}

0 comments on commit 6ceae0a

Please sign in to comment.