-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
190 additions
and
0 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,15 @@ | ||
name: Setup Node | ||
description: Setup Node | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: pnpm/action-setup@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: "pnpm" | ||
|
||
- run: pnpm install | ||
shell: bash |
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,40 @@ | ||
name: Site Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: website-deploy-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node Environment | ||
uses: ./.github/actions/setup-node | ||
|
||
- name: Build Website | ||
run: pnpm app build | ||
|
||
- name: Get Branch Name | ||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV | ||
|
||
- name: Deploy to Netlify | ||
uses: nwtgck/actions-netlify@v3 | ||
with: | ||
publish-dir: "./packages/app/dist" | ||
production-deploy: true | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
deploy-message: "Deploy ${{ env.BRANCH_NAME }}@${{ github.sha }}" | ||
enable-commit-comment: false | ||
alias: ${{ env.BRANCH_NAME }} | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.SITE_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,99 @@ | ||
name: Site Deploy (Preview CD) | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Site Deploy (Preview CI)"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
preview-cd: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: pull-request-preview-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} | ||
cancel-in-progress: true | ||
|
||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
environment: pull request | ||
|
||
permissions: | ||
actions: read | ||
statuses: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Set Commit Status | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.repos.createCommitStatus({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: context.payload.workflow_run.head_sha, | ||
context: 'Website Preview', | ||
description: 'Deploying...', | ||
state: 'pending', | ||
}) | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: website-preview | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Restore Context | ||
run: | | ||
cat action.env >> $GITHUB_ENV | ||
- name: Set Deploy Name | ||
run: | | ||
echo "DEPLOY_NAME=deploy-preview-${{ env.PR_NUMBER }}" >> $GITHUB_ENV | ||
- name: Deploy to Netlify | ||
id: deploy | ||
uses: nwtgck/actions-netlify@v3 | ||
with: | ||
publish-dir: ./packages/app/dist | ||
production-deploy: false | ||
deploy-message: "Deploy ${{ env.DEPLOY_NAME }}@${{ github.event.workflow_run.head_sha }}" | ||
alias: ${{ env.DEPLOY_NAME }} | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.SITE_ID }} | ||
|
||
# action netlify has no pull request context, so we need to comment by ourselves | ||
- name: Comment on Pull Request | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: website | ||
number: ${{ env.PR_NUMBER }} | ||
message: | | ||
:rocket: Deployed to ${{ steps.deploy.outputs.deploy-url }} | ||
- name: Set Commit Status | ||
uses: actions/github-script@v7 | ||
if: always() | ||
with: | ||
script: | | ||
if (`${{ job.status }}` === 'success') { | ||
github.rest.repos.createCommitStatus({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: context.payload.workflow_run.head_sha, | ||
context: 'Website Preview', | ||
description: `Deployed to ${{ steps.deploy.outputs.deploy-url }}`, | ||
state: 'success', | ||
target_url: `${{ steps.deploy.outputs.deploy-url }}`, | ||
}) | ||
} else { | ||
github.rest.repos.createCommitStatus({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: context.payload.workflow_run.head_sha, | ||
context: 'Website Preview', | ||
description: `Deploy ${{ job.status }}`, | ||
state: 'failure', | ||
}) | ||
} |
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: Site Deploy (Preview CI) | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
preview-ci: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: pull-request-preview-${{ github.event.number }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node Environment | ||
uses: ./.github/actions/setup-node | ||
|
||
- name: Build Website | ||
run: pnpm app build | ||
|
||
- name: Export Context | ||
run: | | ||
echo "PR_NUMBER=${{ github.event.number }}" >> ./action.env | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: website-preview | ||
path: | | ||
./packages/app/dist | ||
./action.env | ||
retention-days: 1 |