add preview #90
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: Build and deploy to Kuroco front | |
on: | |
push: | |
branches: | |
- main | |
issue_comment: | |
types: [created, edited] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# for Pull Request (exclude merged) | |
pullreq_build: | |
name: Build(pullreq) | |
if: (github.repository == 'diverta/front_nuxt_auth' && github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/kuroco stage') && github.event.issue.pull_request != null) | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Get branch name and sha" | |
id: get_branch | |
run: | | |
PR=$(curl -H "X-Kuroco-Auth: token 79a0dac07eb8af664820afa615e28575" https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/?pr=${{ github.event.issue.pull_request.url }}) | |
echo "branch=$(echo $PR | jq -r '.ref')" >> $GITHUB_OUTPUT | |
echo "sha=$(echo $PR | jq -r '.sha')" >> $GITHUB_OUTPUT | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.get_branch.outputs.branch }} | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' | |
- name: CI Cache | |
uses: actions/cache@v4 | |
id: node_modules_cache_id | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref_name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }} | |
run: npm ci | |
- name: Generate | |
run: npm run generate | |
- name: Zip artifact for upload | |
run: cd ./.output/public && zip ../../dist.zip . -r | |
- name: Archive Production Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.get_branch.outputs.sha }}-${{ github.run_id }} | |
path: dist.zip | |
retention-days: 1 | |
- name: Wait for Artifact download | |
run: sleep 15 | |
- name: Webhook | |
uses: diverta/workflow-webhook@v3 | |
env: | |
webhook_url: "https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/" | |
webhook_secret: "79a0dac07eb8af664820afa615e28575" | |
data: '{"single_zip":"1","domain":"dev-nuxt-auth.g.kuroco-front.app","pr":"${{ github.event.issue.pull_request.url }}", "repository":"${{ github.repository }}", "run_id":"${{ github.run_id }}", "hash":"${{ steps.get_branch.outputs.sha }}"}' | |
#for Push | |
pushed_build: | |
name: Build(pushed) | |
if: (github.repository == 'diverta/front_nuxt_auth' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' | |
- name: CI Cache | |
uses: actions/cache@v4 | |
id: node_modules_cache_id | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.ref_name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }} | |
run: npm ci | |
- name: Generate | |
run: npm run generate | |
- name: Zip artifact for upload | |
run: cd ./.output/public && zip ../../dist.zip . -r | |
- name: Archive Production Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.sha }}-${{ github.run_id }} | |
path: dist.zip | |
retention-days: 7 | |
- name: Webhook | |
uses: diverta/workflow-webhook@v3 | |
env: | |
webhook_url: "https://dev-nuxt-auth.a.kuroco.app/direct/menu/github/" | |
webhook_secret: "79a0dac07eb8af664820afa615e28575" | |
data: '{"single_zip":"1","domain":"dev-nuxt-auth.g.kuroco-front.app", "repository":"${{ github.repository }}", "run_id":"${{ github.run_id }}", "hash":"${{ github.sha }}"}' |