Skip to content

Commit 3331332

Browse files
committed
Tighten cpflow workflow permissions and triggers
1 parent ce23e0a commit 3331332

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

.github/actions/cpflow-setup-environment/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ runs:
8383
exit 1
8484
fi
8585
86-
# Persist the token for later cpflow/cpln steps via env. Use a randomized
87-
# delimiter so a multiline token cannot terminate the heredoc early.
86+
# Persist the token because later cpflow/cpln steps read CPLN_TOKEN directly.
87+
# Use a randomized delimiter so a multiline token cannot terminate the heredoc early.
8888
delim="CPLN_TOKEN_$(openssl rand -hex 8)"
8989
{
9090
echo "CPLN_TOKEN<<${delim}"

.github/workflows/cpflow-deploy-review-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run-name: "Deploy Review App - PR #${{ github.event.pull_request.number || githu
44

55
on:
66
pull_request:
7-
types: [opened, synchronize, reopened]
7+
types: [synchronize, reopened]
88
issue_comment:
99
# Slash-command workflow changes run from the default branch until merged.
1010
# Test PR-branch edits with:

.github/workflows/cpflow-promote-staging-to-production.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
type: string
1010

1111
permissions:
12-
contents: write # Required for `gh release create` in the "Create GitHub release" step.
12+
contents: read
1313

1414
env:
1515
# Override these by editing this file or by setting the matching repository variable.
@@ -383,25 +383,6 @@ jobs:
383383
fi
384384
done
385385
386-
- name: Create GitHub release
387-
if: success() && steps.health-check.outputs.healthy == 'true'
388-
env:
389-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
390-
GITHUB_RUN_ID: ${{ github.run_id }}
391-
STAGING_APP_NAME: ${{ vars.STAGING_APP_NAME }}
392-
PRODUCTION_APP_NAME: ${{ vars.PRODUCTION_APP_NAME }}
393-
shell: bash
394-
run: |
395-
set -euo pipefail
396-
397-
release_date="$(date '+%Y-%m-%d')"
398-
timestamp="$(date '+%H%M%S')"
399-
release_tag="production-${release_date}-${timestamp}-${GITHUB_RUN_ID}"
400-
401-
gh release create "${release_tag}" \
402-
--title "Production Release ${release_date} ${timestamp}" \
403-
--notes "Promoted ${STAGING_APP_NAME} to ${PRODUCTION_APP_NAME} on ${release_date} at ${timestamp}."
404-
405386
- name: Promotion summary
406387
if: always()
407388
env:
@@ -422,3 +403,31 @@ jobs:
422403
echo "Previous image (first container of selected/first workload): \`${PREVIOUS_IMAGE}\`"
423404
echo "Previous version: ${PREVIOUS_VERSION}"
424405
} >> "$GITHUB_STEP_SUMMARY"
406+
407+
create-release:
408+
needs: promote-to-production
409+
if: needs.promote-to-production.result == 'success'
410+
runs-on: ubuntu-latest
411+
timeout-minutes: 5
412+
permissions:
413+
contents: write
414+
415+
steps:
416+
- name: Create GitHub release
417+
env:
418+
GH_REPO: ${{ github.repository }}
419+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
420+
GITHUB_RUN_ID: ${{ github.run_id }}
421+
STAGING_APP_NAME: ${{ vars.STAGING_APP_NAME }}
422+
PRODUCTION_APP_NAME: ${{ vars.PRODUCTION_APP_NAME }}
423+
shell: bash
424+
run: |
425+
set -euo pipefail
426+
427+
release_date="$(date '+%Y-%m-%d')"
428+
timestamp="$(date '+%H%M%S')"
429+
release_tag="production-${release_date}-${timestamp}-${GITHUB_RUN_ID}"
430+
431+
gh release create "${release_tag}" \
432+
--title "Production Release ${release_date} ${timestamp}" \
433+
--notes "Promoted ${STAGING_APP_NAME} to ${PRODUCTION_APP_NAME} on ${release_date} at ${timestamp}."

0 commit comments

Comments
 (0)