Skip to content

Commit

Permalink
chore: fix workflow (#1351)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid committed Aug 1, 2023
1 parent 5d88626 commit 6d569cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name: Pull, build docker image and push to repository
on:
on:
workflow_call:
secrets:
GHCR_USERNAME:
required: true
GHCR_TOKEN:
required: true
outputs:
image:
description: URL for docker image with tag
value: ${{ jobs.build.outputs.image }}
jobs:
# Image name
image-name:
description: URL for docker image
value: ${{ jobs.build.outputs.image-name }}
# Image tag (version)
image-tag:
description: image tag(version)
value: ${{ jobs.build.outputs.image-tag }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ jobs:
with:
k8s-namespace: mainnet
k8s-workload: ${{ matrix.workload }}
image: ${{ needs.build.outputs.image }}
image-name: ${{ needs.build.outputs.image-name }}
image-tag: ${{ needs.build.outputs.image-tag }}
secrets: inherit
9 changes: 5 additions & 4 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Deploy to staging

on:
on:
push:
branches:
- develop
Expand All @@ -10,16 +10,17 @@ on:
- '*-rc*'
jobs:
build:
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/build.yml
secrets: inherit
deploy-update:
needs: build
strategy:
matrix:
workload: [ckb-explorer-api, ckb-explorer-syncer, ckb-explorer-worker]
uses: ./.github/workflows/update-image.yml
uses: ./.github/workflows/update-image.yml
with:
k8s-namespace: staging
k8s-workload: ${{ matrix.workload }}
image: ${{ needs.build.outputs.image }}
image-name: ${{ needs.build.outputs.image-name }}
image-tag: ${{ needs.build.outputs.image-tag }}
secrets: inherit
9 changes: 5 additions & 4 deletions .github/workflows/testnet.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: Deploy to testnet

on:
on:
push:
branches:
- testnet
jobs:
build:
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/build.yml
secrets: inherit
deploy-update:
needs: build
strategy:
matrix:
workload: [ckb-explorer-api, ckb-explorer-syncer, ckb-explorer-worker]
uses: ./.github/workflows/update-image.yml
uses: ./.github/workflows/update-image.yml
with:
k8s-namespace: testnet
k8s-workload: ${{ matrix.workload }}
image: ${{ needs.build.outputs.image }}
image-name: ${{ needs.build.outputs.image-name }}
image-tag: ${{ needs.build.outputs.image-tag }}
secrets: inherit
20 changes: 8 additions & 12 deletions .github/workflows/update-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Update K8S workload image
on:
on:
workflow_call:
inputs:
image:
image:
required: true
type: string
k8s-namespace:
Expand All @@ -24,18 +24,14 @@ jobs:

steps:
- name: Update image on K8S
id: http-request
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":{"${{ inputs.k8s-workload }}":"${{ inputs.image }}"}}'
- 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 }}"}'


data: '{"kind":"deployments","namespace":"${{ inputs.k8s-namespace }}","name":"${{ inputs.k8s-workload }}","images":{"${{ inputs.image-name }}":"${{ inputs.image-name }}:${{ inputs.image-tag }}"}}'
- name: Display Response
run: |
echo "Response response: ${{ steps.http-request.outputs.response }}"
echo "Response headers: ${{ steps.http-request.outputs.headers }}"

0 comments on commit 6d569cb

Please sign in to comment.