Skip to content

Promote snap to default track, standard risk levels. #4

Promote snap to default track, standard risk levels.

Promote snap to default track, standard risk levels. #4

Workflow file for this run

# 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', 'core24/edge -> core24/candidate', 'core24/candidate -> core24/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 }}