mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
environment based deploys
This commit is contained in:
1 parent
10c8ac95a4
commit
754f39f623
1 file changed
+38
-19
@@ -2,20 +2,39 @@ name: Website
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
workflow_dispatch:
|
branches:
|
||||||
|
- production
|
||||||
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 4 * * *"
|
- cron: "0 4 * * *"
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
environment:
|
||||||
|
description: Environment
|
||||||
|
|
||||||
|
required: true
|
||||||
|
# default: production
|
||||||
|
default: beta
|
||||||
|
type: choice
|
||||||
|
|
||||||
|
options:
|
||||||
|
- development
|
||||||
|
- beta
|
||||||
|
- production
|
||||||
|
- preview
|
||||||
|
- opentest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
# cancel-in-progress: ${{ github.ref == 'refs/heads/main' }}
|
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
ENVIRONMENT: ${{ inputs.environment || 'production' }}
|
||||||
|
|
||||||
# blitzkit
|
# blitzkit
|
||||||
PUBLIC_BRANCH: main
|
PUBLIC_BRANCH: main
|
||||||
PUBLIC_PROMOTE_OPENTEST: false
|
PUBLIC_PROMOTE_OPENTEST: false
|
||||||
@@ -48,14 +67,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
chunk: [default, api]
|
||||||
- chunk: default
|
|
||||||
node: blitzkit/blitzkit.github.io
|
|
||||||
path: dist/website
|
|
||||||
|
|
||||||
- chunk: api
|
|
||||||
node: blitzkit/api
|
|
||||||
path: dist/website/api
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Free disk space
|
- name: Free disk space
|
||||||
@@ -118,24 +130,31 @@ jobs:
|
|||||||
run: bun run --bun build
|
run: bun run --bun build
|
||||||
env:
|
env:
|
||||||
CHUNK: ${{ matrix.chunk }}
|
CHUNK: ${{ matrix.chunk }}
|
||||||
|
ENVIRONMENT: ${{ env.ENVIRONMENT }}
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
id: upload
|
id: upload
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: chunk-${{ matrix.chunk }}
|
name: chunk-${{ matrix.chunk }}
|
||||||
path: ${{ matrix.path }}
|
path: dist/website
|
||||||
|
|
||||||
- name: Save artifact ID
|
|
||||||
run: |
|
|
||||||
echo "${{ steps.upload.outputs.artifact-id }}"
|
|
||||||
|
|
||||||
- name: Trigger deployment
|
- name: Trigger deployment
|
||||||
|
|
||||||
|
if: github.ref_name == 'production' || github.ref_name == 'infrastructure'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GH_NODE_DEPLOY_TOKEN }}
|
TOKEN: ${{ secrets.GH_NODE_DEPLOY_TOKEN }}
|
||||||
ARTIFACT_ID: ${{ steps.upload.outputs.artifact-id }}
|
CHUNK: ${{ matrix.chunk }}
|
||||||
TARGET_REPO: ${{ matrix.node }}
|
|
||||||
run: |
|
run: |
|
||||||
|
ENV_FILE="environments/${ENVIRONMENT}.json"
|
||||||
|
TARGET_REPO=$(jq -r ".nodes.\"$CHUNK\"" "$ENV_FILE")
|
||||||
|
|
||||||
|
if [ "$TARGET_REPO" == "null" ] || [ -z "$TARGET_REPO" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
curl \
|
curl \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Accept: application/vnd.github+json" \
|
-H "Accept: application/vnd.github+json" \
|
||||||
@@ -146,7 +165,7 @@ jobs:
|
|||||||
\"client_payload\": {
|
\"client_payload\": {
|
||||||
\"source_repo\": \"${{ github.repository }}\",
|
\"source_repo\": \"${{ github.repository }}\",
|
||||||
\"run_id\": \"${{ github.run_id }}\",
|
\"run_id\": \"${{ github.run_id }}\",
|
||||||
\"artifact_id\": \"$ARTIFACT_ID\",
|
\"artifact_id\": \"${{ steps.upload.outputs.artifact-id }}\",
|
||||||
\"chunk\": \"${{ matrix.chunk }}\"
|
\"chunk\": \"$CHUNK\"
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
Reference in new issue
Block a user