Promote Train #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Promote Train | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: "Dry-run (only print promotions)" | |
type: boolean | |
default: false | |
required: true | |
jobs: | |
promote: | |
name: Promote Charm | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
charm-repo: | |
- alertmanager-k8s-operator | |
- avalanche-k8s-operator | |
- blackbox-exporter-k8s-operator | |
- catalogue-k8s-operator | |
- cos-configuration-k8s-operator | |
- cos-proxy-operator | |
- grafana-agent-k8s-operator | |
- grafana-agent-operator | |
- grafana-k8s-operator | |
- karma-alertmanager-proxy-k8s-operator | |
- karma-k8s-operator | |
- loki-k8s-operator | |
- mimir-coordinator-k8s-operator | |
- mimir-worker-k8s-operator | |
- prometheus-k8s-operator | |
- prometheus-pushgateway-k8s-operator | |
- prometheus-scrape-config-k8s-operator | |
- prometheus-scrape-target-k8s-operator | |
- tempo-k8s-operator | |
- traefik-k8s-operator | |
- traefik-route-k8s-operator | |
steps: | |
- name: Checkout the charm repository | |
uses: actions/checkout@v4 | |
with: | |
repository: canonical/${{ matrix.charm-repo }} | |
- name: Read the charm path from the Promote workflow | |
id: read-charm-path | |
run: | | |
CHARM_PATH=$(yq -r .jobs.promote.with.charm-path .github/workflows/promote.yaml) | |
if [[ "$CHARM_PATH" == "null" ]]; then | |
echo "charm_path=." >> $GITHUB_OUTPUT; | |
else | |
echo "charm_path=$CHARM_PATH" >> $GITHUB_OUTPUT; | |
fi | |
- name: Check which tracks already have a release | |
id: check-tracks | |
env: | |
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }} | |
run: | | |
sudo snap install charmcraft --classic | |
cd ${{ steps.read-charm-path.outputs.charm_path }} | |
charm_name=$(yq .name metadata.yaml 2>/dev/null || yq .name charmcraft.yaml) | |
status=$(charmcraft status "$charm_name" --format=json) | |
to_stable=$(echo "$status" | jq -r '.[] | select(.track == "latest") | .mappings[].releases[] | select(.channel == "latest/stable") | .status' | head -n1) | |
to_candidate=$(echo "$status" | jq -r '.[] | select(.track == "latest") | .mappings[].releases[] | select(.channel == "latest/candidate") | .status' | head -n1) | |
to_beta=$(echo "$status" | jq -r '.[] | select(.track == "latest") | .mappings[].releases[] | select(.channel == "latest/beta") | .status' | head -n1) | |
echo "to_stable=$to_stable" >> $GITHUB_OUTPUT | |
echo "to_candidate=$to_candidate" >> $GITHUB_OUTPUT | |
echo "to_beta=$to_beta" >> $GITHUB_OUTPUT | |
- name: (dry run) Print promotions | |
if: ${{ inputs.dry-run }} | |
run: | | |
echo "${{ matrix.charm-repo }} would promote the following channels:" | |
if [[ "${{ steps.check-tracks.outputs.to_stable }}" == "open" ]]; then echo "- latest/candidate --> latest/stable"; fi | |
if [[ "${{ steps.check-tracks.outputs.to_candidate }}" == "open" ]]; then echo "- latest/beta --> latest/candidate"; fi | |
if [[ "${{ steps.check-tracks.outputs.to_beta }}" == "open" ]]; then echo "- latest/edge --> latest/beta"; fi | |
- name: Promote charm - latest/candidate --> latest/stable | |
if: ${{ !inputs.dry-run && steps.check-tracks.outputs.to_stable == 'open' }} | |
uses: canonical/charming-actions/[email protected] | |
with: | |
charm-path: ${{ steps.read-charm-path.outputs.charm_path }} | |
credentials: ${{ secrets.CHARMHUB_TOKEN }} | |
origin-channel: latest/candidate | |
destination-channel: latest/stable | |
- name: Promote charm - latest/beta --> latest/candidate | |
if: ${{ !inputs.dry-run && steps.check-tracks.outputs.to_candidate == 'open' }} | |
uses: canonical/charming-actions/[email protected] | |
with: | |
charm-path: ${{ steps.read-charm-path.outputs.charm_path }} | |
credentials: ${{ secrets.CHARMHUB_TOKEN }} | |
origin-channel: latest/beta | |
destination-channel: latest/candidate | |
- name: Promote charm - latest/edge --> latest/beta | |
if: ${{ !inputs.dry-run && steps.check-tracks.outputs.to_beta == 'open' }} | |
uses: canonical/charming-actions/[email protected] | |
with: | |
charm-path: ${{ steps.read-charm-path.outputs.charm_path }} | |
credentials: ${{ secrets.CHARMHUB_TOKEN }} | |
origin-channel: latest/edge | |
destination-channel: latest/beta |