Skip to content

add: Member Only Article #47

add: Member Only Article

add: Member Only Article #47

Workflow file for this run

name: Build and deploy to Kuroco front (PROD)
on:
push:
branches:
- main
issue_comment:
types: [created, edited]
workflow_dispatch:
env:
BRANCH: main
jobs:
# for Pull Request (exclude merged)
pullreq_build:
name: Build(pullreq)
if: (github.repository == 'diverta/front_next_media' && 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 "Authorization: token de396df5ef2cadeccd5e053c2975a9f0" https://dev-next-media.g.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@v3
with:
ref: ${{ steps.get_branch.outputs.branch }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
- name: Install dependencies
run: npm ci
# - name: Copy .env.prod file
# run: cp .env.prod .env
- name: Build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
uses: nick-fields/retry@v2
with:
timeout_minutes: 60
max_attempts: 3
retry_on: error
command: npm run build
- name: Zip artifact for upload
run: cd out && zip ../out.zip . -r
- name: Archive Production Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_branch.outputs.sha }}-${{ github.run_id }}
path: out.zip
retention-days: 7
- name: Wait for Artifact download
run: sleep 15
- name: Webhook
uses: diverta/workflow-webhook@v2
env:
webhook_url: "https://dev-next-media.g.kuroco.app/direct/menu/github/"
webhook_secret: "de396df5ef2cadeccd5e053c2975a9f0"
data: '{"single_zip":"1","domain":"dev-next-media.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_next_media' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch'))
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
- name: Install dependencies
run: npm ci
# - name: Copy .env prod file
# run: cp .env.prod .env
- name: Build
env:
NODE_OPTIONS: "--max_old_space_size=4096"
uses: nick-fields/retry@v2
with:
timeout_minutes: 60
max_attempts: 3
retry_on: error
command: npm run build
- name: Zip artifact for upload
run: cd out && zip ../out.zip . -r
- name: Archive Production Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ github.run_id }}
path: out.zip
retention-days: 7
- name: Webhook
uses: diverta/workflow-webhook@v2
env:
webhook_url: "https://dev-next-media.g.kuroco.app/direct/menu/github/"
webhook_secret: "de396df5ef2cadeccd5e053c2975a9f0"
data: '{"single_zip":"1","domain":"dev-next-media.g.kuroco-front.app", "repository":"${{ github.repository }}", "run_id":"${{ github.run_id }}", "hash":"${{ github.sha }}"}'