Skip to content

Commit

Permalink
ci: Dropdown for promote.yaml (#29)
Browse files Browse the repository at this point in the history
- Provide default track and risk levels as dropdown in promote.yaml

(planned but not in scope for this PR) - For some projects need to
release to different track/risk-levels, we provide another customized
file instead using standard one.
  • Loading branch information
jneo8 authored Jun 12, 2024
1 parent 5852e5e commit 080a80c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
25 changes: 17 additions & 8 deletions terraform-plans/files/github/charm_promote.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
name: Promote charm to other tracks and channels
name: Promote charm to default track, standard risk levels.

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel, e.g. latest/candidate'
required: true
origin-channel:
description: 'Origin Channel, e.g. latest/edge'
channel-promotion:
description: 'Channel Promotion, e.g. latest/edge -> latest/candidate'
required: true
type: choice
options:
- 'latest/edge -> latest/candidate'
- 'latest/candidate -> latest/stable'

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set channels
id: set-channels
run: |
channel_promotion="$${{ github.event.inputs.channel-promotion }}"
origin=$(echo "$channel_promotion" | sed 's/\s*->.*//')
destination=$(echo "$channel_promotion" | sed 's/.*->\s*//')
echo "destination-channel=$destination" >> $GITHUB_OUTPUT
echo "origin-channel=$origin" >> $GITHUB_OUTPUT
- name: Release charm to channel
uses: canonical/charming-actions/[email protected]
with:
credentials: $${{ secrets.CHARMHUB_TOKEN }}
github-token: $${{ secrets.GITHUB_TOKEN }}
destination-channel: $${{ github.event.inputs.destination-channel }}
origin-channel: $${{ github.event.inputs.origin-channel }}
destination-channel: $${{ steps.set-channels.outputs.destination-channel }}
origin-channel: $${{ steps.set-channels.outputs.origin-channel }}
25 changes: 17 additions & 8 deletions terraform-plans/files/github/snap_promote.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Promote snap to other tracks and channels
name: Promote snap to default track, standard risk levels.

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel, e.g. latest/candidate'
required: true
origin-channel:
description: 'Origin Channel, e.g. latest/edge'
channel-promotion:
description: 'Channel Promotion, e.g. latest/edge -> latest/candidate'
required: true
type: choice
options:
- 'latest/edge -> latest/candidate'
- 'latest/candidate -> latest/stable'

jobs:
promote-snap:
Expand All @@ -21,6 +22,14 @@ jobs:
- name: Get snap name
id: snap
run: echo "name=$(awk '/^name:/ {print $2}' snap/snapcraft.yaml)" >> "$GITHUB_OUTPUT"
- name: Set channels
id: set-channels
run: |
channel_promotion="$${{ github.event.inputs.channel-promotion }}"
origin=$(echo "$channel_promotion" | sed 's/\s*->.*//')
destination=$(echo "$channel_promotion" | sed 's/.*->\s*//')
echo "destination-channel=$destination" >> $GITHUB_OUTPUT
echo "origin-channel=$origin" >> $GITHUB_OUTPUT
- name: Snapcraft promote snap
env:
SNAPCRAFT_STORE_CREDENTIALS: $${{ secrets.STORE_LOGIN }}
Expand All @@ -30,5 +39,5 @@ jobs:
# refuse to non-interactively promote a snap from the edge
# channel if it is done without any branch qualifiers
yes | snapcraft promote $${{ steps.snap.outputs.name }} \
--from-channel $${{ github.event.inputs.origin-channel }} \
--to-channel $${{ github.event.inputs.destination-channel }}
--from-channel $${{ steps.set-channels.outputs.origin-channel }} \
--to-channel $${{ steps.set-channels.outputs.destination-channel }}

0 comments on commit 080a80c

Please sign in to comment.