Release #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
name: Release | |
on: | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
ref: | |
description: 'Reference to deploy' | |
type: string | |
default: 'latest/production' | |
secrets: | |
HYGRAPH_AUTH_TOKEN: | |
required: true | |
DOKKU_DEPLOY_KEY: | |
required: true | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ inputs.ref || 'latest/production' }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: .nvmrc | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Migrate db | |
run: yarn prisma migrate deploy | |
- name: Pull data | |
run: yarn pull | |
env: | |
HYGRAPH_AUTH_TOKEN: ${{ secrets.HYGRAPH_AUTH_TOKEN }} | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Build | |
run: yarn build | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DOKKU_DEPLOY_KEY }} | |
- run: echo '167.71.190.115 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEYg+BGxM8IdEoQ8fx7aDoclC0eNXSpI6l/QkLRMF/cvjJcSCk4kz/4LEkSU8eXFawp8IX/yNOyV11sJZtCVBCs=' >> ~/.ssh/known_hosts | |
- run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Deploy Bot" | |
git remote add dokku [email protected]:yummy-next | |
git add . | |
git add --force .next | |
git add --force prisma | |
git commit -m 'Update' | |
git push dokku HEAD:master --force | |
- uses: rickstaa/action-create-tag@v1 | |
if: inputs.ref && inputs.ref != 'latest/production' | |
with: | |
commit_sha: ${{ inputs.ref }} | |
tag: 'latest/production' | |
force_push_tag: true | |
message: 'Latest production release' | |
github_token: ${{ secrets.GITHUB_TOKEN }} |