-
Notifications
You must be signed in to change notification settings - Fork 147
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 #803 from bemusic/cd-release
Set up deployment pipeline for the new release workflow
- Loading branch information
Showing
9 changed files
with
246 additions
and
90 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 |
---|---|---|
|
@@ -30,38 +30,33 @@ jobs: | |
node build-scripts build | ||
env: | ||
SCOREBOARD_SERVER: ${{ secrets.SCOREBOARD_SERVER }} | ||
- name: Compress build output | ||
if: always() | ||
run: tar -cvzf dist.tar.gz dist | ||
- name: Checks | ||
run: node build-scripts pre-deploy | ||
- name: Deploy | ||
if: false | ||
- name: Release | ||
if: github.event_name == 'push' | ||
id: release | ||
run: | | ||
if git log --format=%B -n 1 | egrep '^:bookmark: v[0-9]+\.[0-9]+\.[0-9]+' | ||
then | ||
if [ -n "$GH_APP_CREDENTIALS_TOKEN" ] | ||
then | ||
GH_TOKEN="$(npx obtain-github-app-installation-access-token ci $GH_APP_CREDENTIALS_TOKEN)" | ||
echo "::add-mask::$GH_TOKEN" | ||
git remote add www https://akibot:[email protected]/bemusic/bemusic.github.io.git | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Aki running on GitHub Actions" | ||
node build-scripts deploy | ||
else | ||
echo "GH_APP_CREDENTIALS_TOKEN is not set, skipped" | ||
fi | ||
else | ||
echo 'Not a release commit, skipped!' | ||
fi | ||
node build-scripts release --confirm | ||
env: | ||
GH_APP_CREDENTIALS_TOKEN: ${{ secrets.GH_APP_CREDENTIALS_TOKEN }} | ||
- name: Compress build output | ||
if: always() | ||
run: tar -cvzf dist.tar.gz dist | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload artifact | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bemuse-build-${{ github.sha }} | ||
path: dist.tar.gz | ||
outputs: | ||
released-tag: ${{ steps.release.outputs.tag }} | ||
deploy: | ||
uses: ./.github/workflows/deploy-production.yml | ||
needs: build | ||
secrets: inherit | ||
if: needs.build.outputs.released-tag | ||
with: | ||
tag: ${{ needs.build.outputs.released-tag }} | ||
e2e: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
@@ -157,3 +152,38 @@ jobs: | |
- uses: codecov/codecov-action@v2 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
changelog: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' | ||
env: | ||
AUTHOR: ${{ github.event.pull_request.user.login }} | ||
PR: ${{ github.event.pull_request.number }} | ||
PR_NEW_FILE_URL: | ||
https://github.com/${{ github.event.pull_request.head.repo.full_name | ||
}}/new/${{ github.event.pull_request.head.ref }} | ||
steps: | ||
- name: Generate changelog file | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const path = `changelog/pr-${process.env.PR}.md` | ||
const contents = [ | ||
'---', | ||
'author: ' + process.env.AUTHOR, | ||
'category: feature/internals/bugfix/improvement', | ||
'type: major/minor/patch', | ||
'pr: ' + process.env.PR, | ||
'---', | ||
'', | ||
'(Write your changelog entry here)', | ||
].join('\n') | ||
const url = `${process.env.PR_NEW_FILE_URL}?filename=${encodeURIComponent(path)}&value=${encodeURIComponent(contents)}` | ||
const summary = `[Click here to create a changelog entry.](${url})` | ||
require('fs').appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary) | ||
console.log('To create a changelog entry, create a file at', path) | ||
console.log('') | ||
console.log('Example contents:') | ||
console.log('') | ||
console.log(contents) | ||
console.log('') | ||
console.log(url) |
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,58 @@ | ||
name: Deploy to production | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Git tag to deploy' | ||
required: true | ||
workflow_call: | ||
inputs: | ||
tag: | ||
description: 'Git tag to deploy' | ||
required: true | ||
type: 'string' | ||
secrets: | ||
GH_APP_CREDENTIALS_TOKEN: | ||
description: 'GitHub App credentials token' | ||
required: true | ||
|
||
env: | ||
NODE_FLAGS: --max_old_space_size=4096 | ||
TAG: ${{ inputs.tag }} | ||
|
||
jobs: | ||
deploy: | ||
environment: | ||
name: Production | ||
url: https://bemuse.ninja | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up project | ||
uses: ./.github/actions/setup-project | ||
- name: Download release | ||
run: | | ||
gh release download $TAG --pattern dist.tar.gz | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract build | ||
run: tar -xvzf dist.tar.gz | ||
- name: Checks | ||
run: node build-scripts pre-deploy | ||
- name: Deploy | ||
run: | | ||
if [ -n "$GH_APP_CREDENTIALS_TOKEN" ] | ||
then | ||
GH_TOKEN="$(npx obtain-github-app-installation-access-token ci $GH_APP_CREDENTIALS_TOKEN)" | ||
echo "::add-mask::$GH_TOKEN" | ||
git remote add www https://akibot:[email protected]/bemusic/bemusic.github.io.git | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Aki running on GitHub Actions" | ||
node build-scripts deploy | ||
else | ||
echo "GH_APP_CREDENTIALS_TOKEN is not set, skipped" | ||
fi | ||
env: | ||
GH_APP_CREDENTIALS_TOKEN: ${{ secrets.GH_APP_CREDENTIALS_TOKEN }} |
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ pnpm-lock.yaml | |
yarn.lock | ||
package-lock.json | ||
shrinkwrap.json | ||
**/*.md | ||
**/*.md | ||
changelog/*.md |
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
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
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
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,8 @@ | ||
--- | ||
author: dtinth | ||
category: internals | ||
type: minor | ||
pr: 803 | ||
--- | ||
|
||
Revamped the deployment pipeline to streamline [the release process](https://bemuse.ninja/project/docs/workflows/). |
Oops, something went wrong.