-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "ci: merge preview workflows" (#45380)
* Revert "ci: merge preview workflows (#45276)" This reverts commit 0379ee5b6852ce8725037138d22281d975fa274d. * chore: clean tmp test
- Loading branch information
Showing
4 changed files
with
259 additions
and
208 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,122 @@ | ||
# Each PR will build preview site that help to check code is work as expect. | ||
|
||
name: Preview Build | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
# Cancel prev CI if new commit come | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# Prepare node modules. Reuse cache if available | ||
setup: | ||
name: prepare preview | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: cache package-lock.json | ||
uses: actions/cache@v3 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: create package-lock.json | ||
run: npm i --package-lock-only --ignore-scripts | ||
|
||
- name: hack for single file | ||
run: | | ||
if [ ! -d "package-temp-dir" ]; then | ||
mkdir package-temp-dir | ||
fi | ||
cp package-lock.json package-temp-dir | ||
- name: cache node_modules | ||
id: node_modules_cache_id | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: install | ||
if: steps.node_modules_cache_id.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
build-site: | ||
name: build preview | ||
runs-on: ubuntu-latest | ||
needs: setup | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v3 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: npm run site | ||
id: site | ||
run: npm run site | ||
env: | ||
SITE_ENV: development | ||
NODE_OPTIONS: "--max_old_space_size=4096 --openssl-legacy-provider" | ||
|
||
- name: upload site artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: site | ||
path: _site/ | ||
retention-days: 5 | ||
|
||
# Upload PR id for next workflow use | ||
- name: Save PR number | ||
if: ${{ always() }} | ||
run: echo ${{ github.event.number }} > ./pr-id.txt | ||
|
||
- name: Upload PR number | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pr | ||
path: ./pr-id.txt | ||
|
||
site-test: | ||
name: site E2E test | ||
runs-on: ubuntu-latest | ||
needs: [setup, build-site] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: restore cache from package-lock.json | ||
uses: actions/cache@v3 | ||
with: | ||
path: package-temp-dir | ||
key: lock-${{ github.sha }} | ||
|
||
- name: restore cache from node_modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} | ||
|
||
- name: download site artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: site | ||
path: _site |
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,106 @@ | ||
# Each PR will build preview site that help to check code is work as expect. | ||
|
||
name: Preview Deploy | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Preview Build"] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy-site: | ||
permissions: | ||
actions: read # for dawidd6/action-download-artifact to query and download artifacts | ||
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments | ||
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments | ||
name: deploy preview | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
# We need get PR id first | ||
- name: download pr artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: pr | ||
|
||
# Save PR id to output | ||
- name: save PR id | ||
id: pr | ||
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT | ||
|
||
# Download site artifact | ||
- name: download site artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: site | ||
|
||
- name: upload surge service | ||
id: deploy | ||
run: | | ||
export DEPLOY_DOMAIN=https://preview-${{ steps.pr.outputs.id }}-ant-design.surge.sh | ||
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }} | ||
- name: update status comment | ||
uses: actions-cool/maintain-one-comment@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
[<img width="306" src="https://user-images.githubusercontent.com/5378891/72400743-23dbb200-3785-11ea-9d13-1a2d92743846.png">](https://preview-${{ steps.pr.outputs.id }}-ant-design.surge.sh) | ||
<!-- AUTO_PREVIEW_HOOK --> | ||
body-include: '<!-- AUTO_PREVIEW_HOOK -->' | ||
number: ${{ steps.pr.outputs.id }} | ||
|
||
- name: The job has failed | ||
if: ${{ failure() }} | ||
uses: actions-cool/maintain-one-comment@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
<img width="534" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png"> | ||
<!-- AUTO_PREVIEW_HOOK --> | ||
body-include: '<!-- AUTO_PREVIEW_HOOK -->' | ||
number: ${{ steps.pr.outputs.id }} | ||
|
||
build-site-failed: | ||
permissions: | ||
actions: read # for dawidd6/action-download-artifact to query and download artifacts | ||
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments | ||
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments | ||
name: build preview failed | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'failure' | ||
steps: | ||
# We need get PR id first | ||
- name: download pr artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
name: pr | ||
|
||
# Save PR id to output | ||
- name: save PR id | ||
id: pr | ||
run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT | ||
|
||
- name: The job has failed | ||
uses: actions-cool/maintain-one-comment@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
<img width="534" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png"> | ||
<!-- AUTO_PREVIEW_HOOK --> | ||
body-include: '<!-- AUTO_PREVIEW_HOOK -->' | ||
number: ${{ steps.pr.outputs.id }} |
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,31 @@ | ||
# When `preview-build` start. Leave a message on the PR | ||
# | ||
# 🚨🚨🚨 Important 🚨🚨🚨 | ||
# Never do any `checkout` or `npm install` action! | ||
# `pull_request_target` will enable PR to access the secrets! | ||
|
||
name: Preview Start | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, synchronize, reopened] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
preview-start: | ||
permissions: | ||
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments | ||
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments | ||
name: start preview info | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: update status comment | ||
uses: actions-cool/maintain-one-comment@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
 | ||
<!-- AUTO_PREVIEW_HOOK --> | ||
body-include: '<!-- AUTO_PREVIEW_HOOK -->' |
Oops, something went wrong.