forked from nervosnetwork/ckb-explorer-frontend
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github actions to build and deploy to k8s
- Loading branch information
1 parent
fba18af
commit e952b30
Showing
10 changed files
with
101 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.github | ||
.husky | ||
node_modules | ||
dist | ||
build |
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,61 @@ | ||
name: Pull, build, push and deploy | ||
on: | ||
workflow_call: | ||
inputs: | ||
ckb-mode: | ||
required: true | ||
type: string | ||
api-url: | ||
required: true | ||
type: string | ||
k8s-namespace: | ||
required: true | ||
type: string | ||
k8s-workload: | ||
required: true | ||
type: string | ||
secrets: | ||
GHCR_USERNAME: | ||
required: true | ||
GHCR_TOKEN: | ||
required: true | ||
KUBOARD_USERNAME: | ||
required: true | ||
KUBOARD_ACCESS_KEY: | ||
required: true | ||
KUBOARD_API_URL: | ||
required: true | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: mr-smithers-excellent/docker-build-push@v5 | ||
with: | ||
image: ckb-explorer-frontend | ||
registry: ghcr.io | ||
githubOrg: magickbase # optional | ||
buildArgs: "API_URL=${{ inputs.api-url }},CHAIN_TYPE=${{ inputs.ckb-mode }}" | ||
username: ${{ secrets.GHCR_USERNAME }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
- name: Update image on K8S | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: ${{ secrets.KUBOARD_API_URL }}/cluster/ckb/kind/CICDApi/ops/resource/updateImageTag | ||
method: 'PUT' | ||
customHeaders: '{"Content-Type": "application/json", "Cookie": "KuboardUsername=${{ secrets.KUBOARD_USERNAME }}; KuboardAccessKey=${{ secrets.KUBOARD_ACCESS_KEY }}"}' | ||
data: '{"kind":"deployments","namespace":"${{ inputs.k8s-namespace }}","name":"${{ inputs.k8s-workload }}","images":{"ckb-explorer-frontend":"${{ steps.docker_build.outputs.imageFullName }}:${{ steps.docker_build.outputs.tags }}"}}' | ||
- name: Restart container | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: ${{ secrets.KUBOARD_API_URL }}/cluster/ckb/kind/CICDApi/ops/resource/restartWorkload | ||
method: 'PUT' | ||
customHeaders: '{"Content-Type": "application/json", "Cookie": "KuboardUsername=${{ secrets.KUBOARD_USERNAME }}; KuboardAccessKey=${{ secrets.KUBOARD_ACCESS_KEY }}"}' | ||
data: '{"kind":"deployments","namespace":"${{ inputs.k8s-namespace }}","name":"${{ inputs.k8s-workload }}"}' | ||
|
||
|
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 |
---|---|---|
@@ -1,23 +1,17 @@ | ||
name: CI | ||
name: Deploy to mainnet | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
uses: ./.github/workflows/_build_deploy.yml | ||
with: | ||
ckb-mode: mainnet | ||
api-url: $MAINNET_API_URL | ||
k8s-namespace: mainnet | ||
k8s-workload: ckb-explorer-front | ||
secrets: inherit | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to dokku | ||
uses: dokku/github-action@master | ||
with: | ||
# specify the `main` branch as the remote branch to push to | ||
branch: 'main' | ||
git_push_flags: '--force' | ||
git_remote_url: ${{ secrets.MAINNET_HOST_URL }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} |
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 |
---|---|---|
@@ -1,23 +1,15 @@ | ||
name: CI | ||
name: Deploy to staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to dokku | ||
uses: dokku/github-action@master | ||
with: | ||
# specify the `main` branch as the remote branch to push to | ||
branch: 'develop' | ||
git_push_flags: '--force' | ||
git_remote_url: ${{ secrets.STAGING_HOST_URL }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
uses: ./.github/workflows/_build_deploy.yml | ||
with: | ||
ckb-mode: testnet | ||
api-url: $STAGING_API_URL | ||
k8s-namespace: staging | ||
k8s-workload: ckb-explorer-front | ||
secrets: inherit |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: CI | ||
name: Unit Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
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 |
---|---|---|
@@ -1,23 +1,16 @@ | ||
name: CI | ||
name: Deploy to testnet | ||
|
||
on: | ||
push: | ||
branches: | ||
- testnet | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
uses: ./.github/workflows/_build_deploy.yml | ||
with: | ||
ckb-mode: testnet | ||
api-url: $TESTNET_API_URL | ||
k8s-namespace: testnet | ||
k8s-workload: ckb-explorer-front | ||
secrets: inherit | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to dokku | ||
uses: dokku/github-action@master | ||
with: | ||
# specify the `main` branch as the remote branch to push to | ||
branch: 'testnet' | ||
git_push_flags: '--force' | ||
git_remote_url: ${{ secrets.TESTNET_HOST_URL }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ coverage/ | |
*.tmp | ||
*.swo | ||
|
||
.env.local | ||
.secrets | ||
!.secrets.example |
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 @@ | ||
v12.22.8 |
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,4 @@ | ||
GHCR_TOKEN=ghp_.... | ||
GHCR_USERNAME=nervos | ||
KUBOARD_USERNAME=devops | ||
KUBOARD_ACCESS_KEY=... |
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