* chore: replace GH_ACCESS_TOKEN with GitHub App token Replace personal access token (GH_ACCESS_TOKEN) with GitHub App token generation using actions/create-github-app-token@v1 for improved security. Updated workflows: - draft-release.yml - post-release.yml - cleanup.yml - cleanup-report.yml - publish-report.yml - i18n.yml Benefits: - Short-lived tokens (1 hour) vs long-lived PATs - Fine-grained, scoped permissions - Not tied to individual user accounts - Better audit trail Required setup: - Create a GitHub App with contents:write permission - Install the app on calcom/cal.com and calcom/test-results-2 - Add RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY secrets Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: rename secrets to CI_CAL_APP_ID and CI_CAL_APP_PRIVATE_KEY Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: use reusable workflow from calcom-ci-secrets for token generation This isolates the GitHub App private key in a separate repository, ensuring that compromised actions in cal.com can only access short-lived tokens, not the key itself. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: use explicit secret passing instead of secrets: inherit Only pass the two required secrets (CI_CAL_APP_ID, CI_CAL_APP_PRIVATE_KEY) to the reusable workflow instead of inheriting all secrets. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: remove secrets block - using environment secrets from calcom-ci-secrets Secrets are now loaded from the ci-github-app environment in calcom-ci-secrets, so cal.com workflows no longer need to pass them. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: revert to explicit secret passing Environment secrets in cross-repo reusable workflows don't work as expected. Secrets must be passed explicitly from the caller repository. Co-Authored-By: alex@cal.com <me@alexvanandel.com> * chore: generate GitHub App token directly in workflows Remove dependency on calcom-ci-secrets reusable workflow. Token generation is now inline using actions/create-github-app-token pinned to SHA 7e473efe3cb98aa54f8d4bac15400b15fad77d94 (v2.2.0). Co-Authored-By: alex@cal.com <me@alexvanandel.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
107 lines
4.2 KiB
YAML
107 lines
4.2 KiB
YAML
on:
|
|
workflow_call:
|
|
permissions:
|
|
contents: write
|
|
issues: write
|
|
pull-requests: write
|
|
jobs:
|
|
publish-report:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
env:
|
|
# Unique URL path for each workflow run attempt
|
|
HTML_REPORT_URL_PATH: reports/${{ github.head_ref }}/${{ github.run_id }}/${{ github.run_attempt }}
|
|
BRANCH_REPORTS_DIR: reports/${{ github.head_ref }}
|
|
steps:
|
|
- name: Generate GitHub App token
|
|
id: generate-token
|
|
uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94
|
|
with:
|
|
app-id: ${{ secrets.CI_CAL_APP_ID }}
|
|
private-key: ${{ secrets.CI_CAL_APP_PRIVATE_KEY }}
|
|
repositories: 'test-results-2'
|
|
|
|
- name: Checkout GitHub Pages Branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: calcom/test-results-2
|
|
ref: gh-pages
|
|
token: ${{ steps.generate-token.outputs.token }}
|
|
- name: Set Git User
|
|
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
- name: Check for workflow reports
|
|
run: |
|
|
if [ -z "$(ls -A $BRANCH_REPORTS_DIR)" ]; then
|
|
echo "BRANCH_REPORTS_EXIST="false"" >> $GITHUB_ENV
|
|
else
|
|
echo "BRANCH_REPORTS_EXIST="true"" >> $GITHUB_ENV
|
|
fi
|
|
- name: Cleanup old HTML reports
|
|
if: ${{ env.BRANCH_REPORTS_EXIST == 'true' }}
|
|
timeout-minutes: 3
|
|
run: |
|
|
rm -rf $BRANCH_REPORTS_DIR
|
|
git add .
|
|
git commit -m "workflow: remove all reports for branch ${{ github.head_ref }}"
|
|
- name: Download zipped HTML report
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: html-report--attempt-${{ github.run_number }}-${{ github.run_attempt }}
|
|
path: ${{ env.HTML_REPORT_URL_PATH }}
|
|
- name: Push HTML Report
|
|
timeout-minutes: 3
|
|
# commit report, then try push-rebase-loop until it's able to merge the HTML report to the gh-pages branch
|
|
# this is necessary when this job running at least twice at the same time (e.g. through two pushes at the same time)
|
|
run: |
|
|
git add .
|
|
git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
|
|
|
|
while true; do
|
|
git pull --rebase
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to rebase. Please review manually."
|
|
exit 1
|
|
fi
|
|
|
|
git push
|
|
if [ $? -eq 0 ]; then
|
|
echo "Successfully pushed HTML report to repo."
|
|
exit 0
|
|
fi
|
|
done
|
|
- name: Output Report URL as Workflow Annotation
|
|
id: url
|
|
run: |
|
|
FULL_HTML_REPORT_URL=https://calcom.github.io/test-results-2/$HTML_REPORT_URL_PATH
|
|
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL"
|
|
echo "link=$FULL_HTML_REPORT_URL" >> $GITHUB_OUTPUT
|
|
- name: Find Comment
|
|
uses: peter-evans/find-comment@v2
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
comment-author: "github-actions[bot]"
|
|
body-includes: <!-- GENERATED-E2E-RESULTS -->
|
|
- name: Create comment
|
|
if: steps.fc.outputs.comment-id == ''
|
|
uses: peter-evans/create-or-update-comment@v3
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
body: |
|
|
<!-- GENERATED-E2E-RESULTS -->
|
|
## E2E results are ready!
|
|
- [Workflow #${{ github.run_number }}.${{ github.run_attempt }} latest results](${{ steps.url.outputs.link }})
|
|
- name: Update comment
|
|
if: steps.fc.outputs.comment-id != ''
|
|
uses: peter-evans/create-or-update-comment@v3
|
|
with:
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
edit-mode: replace
|
|
body: |
|
|
<!-- GENERATED-E2E-RESULTS -->
|
|
## E2E results are ready!
|
|
- [Workflow #${{ github.run_number }}.${{ github.run_attempt }} latest results](${{ steps.url.outputs.link }})
|