From 0b44d9125ca485f89426edf982649eed4e307eb9 Mon Sep 17 00:00:00 2001 From: Nikos Date: Tue, 17 Oct 2023 15:36:45 +0300 Subject: [PATCH] ci: add channel selection publish logic --- .github/workflows/release.yaml | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5df35a5..d261a25 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,10 +1,33 @@ name: Release to latest/edge on: + workflow_call: + inputs: + source_branch: + description: Github branch from this repo to publish. If blank, will use the default branch + default: '' + required: false + type: string + secrets: + CHARMCRAFT_CREDENTIALS: + required: true + workflow_dispatch: + inputs: + destination_channel: + description: CharmHub channel to publish to + required: false + default: 'latest/edge' + type: string + source_branch: + description: Github branch from this repo to publish. If blank, will use the default branch + required: false + default: '' + type: string push: branches: - main + - track/** jobs: charm-tests: @@ -27,11 +50,24 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Build local images run: make build-image + - name: Select charmhub channel + uses: canonical/charming-actions/channel@631c2d944da2bd12430f1f3a954c8fffcf2385cd # 2.4.0 + id: select-channel + if: ${{ inputs.destination_channel == '' }} + # Combine inputs from different sources to a single canonical value so later steps don't + # need logic for picking the right one + - name: Parse and combine inputs + id: parse-inputs + run: | + # destination_channel + destination_channel="${{ inputs.destination_channel || steps.select-channel.outputs.name }}" + echo "setting output of destination_channel=$destination_channel" + echo "::set-output name=destination_channel::$destination_channel" - name: Upload charm to charmhub uses: kian99/charming-actions/upload-charm@add-local-image-option with: credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" - channel: "latest/edge" + channel: ${{ steps.parse-inputs.outputs.destination_channel }} charm-path: "./charms/openfga-k8s" local-image: "true"