forked from open-sauced/docs
-
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.
feat: add release workflow (open-sauced#1)
* feat: add release workflow * fix: temporary remove missing linter function * docs: update broken badge links
- Loading branch information
Showing
3 changed files
with
177 additions
and
32 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
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,174 @@ | ||
name: "Release" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
docker: | ||
name: Build container | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "☁️ checkout repository" | ||
uses: actions/checkout@v2 | ||
|
||
- name: "🔧 setup buildx" | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: "📦 docker build" | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
tags: ${{ github.repository }}:latest | ||
outputs: type=docker,dest=/tmp/docker.tar | ||
push: false | ||
|
||
- name: "📂 docker artifacts" | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: docker | ||
path: /tmp/docker.tar | ||
|
||
build: | ||
name: Build application | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "☁️ checkout repository" | ||
uses: actions/checkout@v2 | ||
|
||
- name: "🔧 setup node" | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: 16 | ||
|
||
- name: "🔧 setup cache" | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: "🔧 install npm@7" | ||
run: npm i -g npm@7 | ||
|
||
- name: "📦 install dependencies" | ||
run: npm ci | ||
|
||
- name: "🚀 static app" | ||
run: npm run build | ||
|
||
- name: "📂 production artifacts" | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build | ||
path: build | ||
|
||
release: | ||
environment: | ||
name: production | ||
url: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.release.outputs.version }} | ||
name: Semantic release | ||
needs: | ||
- docker | ||
- build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "☁️ checkout repository" | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "🔧 setup node" | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: 16 | ||
|
||
- name: "🔧 setup cache" | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: "🔧 install npm@7" | ||
run: npm i -g npm@7 | ||
|
||
- name: "📦 install dependencies" | ||
run: npm ci | ||
|
||
- name: "📂 download docker artifacts" | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker | ||
path: /tmp | ||
|
||
- name: "📦 load tag" | ||
run: | | ||
docker load --input /tmp/docker.tar | ||
docker image ls -a | ||
- name: "📂 download build artifacts" | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: /tmp/build | ||
|
||
- name: "🚀 release" | ||
id: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REPO_OWNER: ${{ github.repository_owner }} | ||
GIT_AUTHOR_NAME: ${{ github.event.commits[0].author.username }} | ||
GIT_AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }} | ||
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} | ||
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} | ||
run: | | ||
cp -R /tmp/build ./build | ||
npx semantic-release | ||
echo "::set-output name=version::$(cat package.json | jq -r '.version')" | ||
deploy: | ||
name: Deploy to static | ||
needs: | ||
- build | ||
- release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "☁️ checkout repository" | ||
uses: actions/checkout@v2 | ||
|
||
- name: "📂 download artifacts" | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: /home/runner/build | ||
|
||
- name: "📂 copy artifacts" | ||
run: | | ||
cp -R /home/runner/build . | ||
ls -lahH ./build | ||
- name: "🚀 deploy static" | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./build | ||
commit_message: ${{ github.event.head_commit.message }} | ||
enable_jekyll: false | ||
cname: docs.opensauced.pizza | ||
|
||
cleanup: | ||
name: Cleanup actions | ||
needs: | ||
- deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "♻️ remove build artifacts" | ||
uses: geekyeggo/delete-artifact@v1 | ||
with: | ||
name: | | ||
build | ||
docker |
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