-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from repository/fix-preview-action
fix workflow permissions
- Loading branch information
Showing
4 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
types: [opened, reopened, synchronize] | ||
|
||
concurrency: preview-${{ github.ref }} | ||
|
||
jobs: | ||
preview: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
cache: "npm" | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
env: | ||
BASE_URL_OVERRIDE: /pr-preview/pr-${{ github.event.number }}/ | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
path: ./build/ | ||
retention-days: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Deploy Pull Request Preview | ||
|
||
on: | ||
pull_request_target: | ||
types: [closed] | ||
|
||
concurrency: preview-${{ github.event.workflow_run.pull_requests[0].number }} | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cleanup Preview | ||
uses: rossjrw/pr-preview-action@v1.4.4 | ||
with: | ||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | ||
source-dir: ./build/ | ||
action: remove |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,29 @@ | ||
name: Deploy Preview for Pull Request | ||
name: Deploy Pull Request Preview | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
types: [opened, reopened, synchronize, closed] | ||
workflow_run: | ||
workflows: ["Build Pull Request"] | ||
types: | ||
- completed | ||
|
||
concurrency: preview-${{ github.ref }} | ||
concurrency: preview-${{ github.event.workflow_run.pull_requests[0].number }} | ||
|
||
jobs: | ||
preview: | ||
runs-on: ubuntu-latest | ||
if: github.event.action != 'closed' && !github.event.pull_request.merged | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
- name: Download Artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
node-version: 18.x | ||
cache: "npm" | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
env: | ||
BASE_URL_OVERRIDE: /pr-preview/pr-${{ github.event.number }}/ | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: build | ||
path: ./build/ | ||
|
||
- name: Deploy Preview | ||
uses: rossjrw/pr-preview-action@v1.4.4 | ||
with: | ||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | ||
source-dir: ./build/ | ||
|
||
cleanup: | ||
runs-on: ubuntu-latest | ||
if: github.event.action == 'closed' || github.event.pull_request.merged | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cleanup Preview | ||
uses: rossjrw/pr-preview-action@v1.4.4 | ||
with: | ||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | ||
source-dir: ./build/ | ||
action: remove |
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