Skip to content

Commit

Permalink
feat: only promote revisions mentioned in the call for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Dec 5, 2023
1 parent 94092c9 commit 0513473
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions promote-to-stable/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
runs:
using: composite
steps:
- name: Checkout the source
uses: actions/checkout@v4

- name: Parse slash command
id: command
uses: xt0rted/slash-command-action@v2
Expand Down Expand Up @@ -62,11 +65,26 @@ runs:
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
echo "snap-name=$(yq -r '.name' "$yaml_path")" >> "$GITHUB_OUTPUT"
- name: Get valid revisions for promotion
id: valid-revisions
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { body } = github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
return body.match(/\/promote ([0-9,]+)/)[1].split(",").join(" ")
- name: Promote snap to latest/stable
id: promote
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ inputs.store-token }}
snap_name: ${{ steps.yaml-path.outputs.snap-name }}
valid_revisions: ${{ steps.valid-revisions.outputs.result }}
shell: bash
run: |
echo "The command was '${{ steps.command.outputs.command-name }}' with arguments '${{ steps.command.outputs.command-arguments }}'"
Expand Down Expand Up @@ -98,8 +116,12 @@ runs:
released_revs=()
for r in $revs; do
snapcraft release "$snap_name" "$r" "$channel"
released_revs+=("$r")
if [[ "$valid_revisions" =~ (^|[[:space:]])"$r"($|[[:space:]]) ]]; then
snapcraft release "$snap_name" "$r" "$channel"
released_revs+=("$r")
else
echo "Not promoting revision '$r' because the revision is not related to this test."
fi
done
# Get a comma separated list of released revisions
Expand Down

0 comments on commit 0513473

Please sign in to comment.