-
Notifications
You must be signed in to change notification settings - Fork 12
48 lines (46 loc) · 2.15 KB
/
promote.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Promote snap to default track, standard risk levels.
on:
workflow_dispatch:
inputs:
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:
name: Promote snap
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Snapcraft install
run: sudo snap install --classic snapcraft
- 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 }}
SNAPCRAFT_HAS_TTY: "true" # this is necessary because snapcraft will not allow --yes for promotions of the edge channel https://github.com/canonical/snapcraft/issues/4439
run: |
# Note: using `yes |` instead of `--yes` because snapcraft will
# 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 ${{ steps.set-channels.outputs.origin-channel }} \
--to-channel ${{ steps.set-channels.outputs.destination-channel }}