-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add action to deploy assets from PR and delete them when the PR is closed #159
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on: | ||
pull_request_target: | ||
types: [opened, edited, reopened, synchronize] | ||
|
||
jobs: | ||
build_css: | ||
runs-on: ubuntu-latest | ||
env: | ||
source: public/dist/assets | ||
destination: assets/website-2021/pr-${{ github.event.number }}/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create a folder for all of them, rather than putting them directly under website-2021? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could use |
||
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 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if we want to use cdn-dev or cdn. I think cdn-dev is restricted, and if so it may be difficult to show changes to external contributors. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
delete_assets: | ||
runs-on: ubuntu-latest | ||
env: | ||
destination: assets/website-2021/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 }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if deploying automatically is a good idea. It could be unsafe to deploy PRs opened by external contributors, so deploying manually might be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we could use
workflow_dispatch
instead to be on the safe side but we will need to run it manually each time the PR is updated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running manually seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be able to trigger the action only on local PRs (so from branches on that repository) instead of PRs coming from forked repositories. How does that sound?