Skip to content

Commit

Permalink
troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Dec 5, 2023
1 parent 0513473 commit b2c3e04
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions promote-to-stable/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ runs:
reaction-type: "eyes"
allow-edits: "false"
permission-level: write

- name: Get valid revisions for promotion
id: valid-revisions
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const issue = await github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
return issue.data.body.match(/\/promote ([0-9,]+)/)[1].split(",").join(" ")
- name: Install snapcraft
shell: bash
Expand Down Expand Up @@ -65,20 +79,6 @@ 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:
Expand Down Expand Up @@ -114,40 +114,53 @@ runs:
# Iterate over each specified revision and release
revs=$(echo "$revision" | tr "," "\n")
released_revs=()
rejected_revs=()
for r in $revs; do
if [[ "$valid_revisions" =~ (^|[[:space:]])"$r"($|[[:space:]]) ]]; then
snapcraft release "$snap_name" "$r" "$channel"
released_revs+=("$r")
else
rejected_revs+=("$r")
echo "Not promoting revision '$r' because the revision is not related to this test."
fi
done
# Get a comma separated list of released revisions
printf -v joined '%s,' "${released_revs[@]}"
printf -v joined_rejected '%s,' "${rejected_revs[@]}"
echo "revisions=${joined%,}" >> "$GITHUB_OUTPUT"
echo "rejected=${joined_rejected%,}" >> "$GITHUB_OUTPUT"
echo "channel=$channel" >> "$GITHUB_OUTPUT"
echo "done=$done" >> "$GITHUB_OUTPUT"
- name: Comment on call for testing issue
uses: actions/github-script@v7
with:
script: |
let message = ""
if ("${{ steps.promote.outputs.revisions }}".length > 0) {
message += 'The following revisions were released to the `${{ steps.promote.outputs.channel }}` channel: `${{ steps.promote.outputs.revisions }}`. '
}
if ("${{ steps.promote.outputs.rejected }}".length > 0) {
message += 'The following revisions were not released, because they are unrelated to this call for testing: `${{ steps.promote.outputs.rejected }}`. '
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The following revisions were released to the `${{ steps.promote.outputs.channel }}` channel: `${{ steps.promote.outputs.revisions }}`'
body: message
})
- name: Close call for testing issue
if: ${{ steps.promote.outputs.done }} == "done"
uses: actions/github-script@v7
with:
script: |
if ("${{ steps.promote.outputs.done }}" === "done") {
if ("${{ steps.promote.outputs.done }}" === "done" && "${{ steps.promote.outputs.revisions }}".length > 0) {
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand Down

0 comments on commit b2c3e04

Please sign in to comment.