From 57eb6d13f1188e777901fe7c1c03eb268ed6285b Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Mon, 31 Jul 2023 12:18:48 +0800 Subject: [PATCH] chore: fix workflow Signed-off-by: Miles Zhang --- .github/workflows/build.yml | 15 ++++++++++----- .github/workflows/mainnet.yml | 3 ++- .github/workflows/staging.yml | 9 +++++---- .github/workflows/testnet.yml | 9 +++++---- .github/workflows/update-image.yml | 20 ++++++++------------ 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5db9d302..b0257eb19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Pull, build docker image and push to repository -on: +on: workflow_call: secrets: GHCR_USERNAME: @@ -7,10 +7,15 @@ on: 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: diff --git a/.github/workflows/mainnet.yml b/.github/workflows/mainnet.yml index 8ecc89cfe..8ce082a40 100644 --- a/.github/workflows/mainnet.yml +++ b/.github/workflows/mainnet.yml @@ -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 diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 06aa5ca3b..587e0a52e 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -1,6 +1,6 @@ name: Deploy to staging -on: +on: push: branches: - develop @@ -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 diff --git a/.github/workflows/testnet.yml b/.github/workflows/testnet.yml index 271e18a8e..f2aab6127 100644 --- a/.github/workflows/testnet.yml +++ b/.github/workflows/testnet.yml @@ -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 diff --git a/.github/workflows/update-image.yml b/.github/workflows/update-image.yml index a631ca8bc..13f6278dd 100644 --- a/.github/workflows/update-image.yml +++ b/.github/workflows/update-image.yml @@ -1,8 +1,8 @@ name: Update K8S workload image -on: +on: workflow_call: inputs: - image: + image: required: true type: string k8s-namespace: @@ -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 }}"