Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions .github/workflows/preview_pages_managment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ jobs:
core.setOutput('sha', pr.data.head.sha);
core.setOutput('ref', pr.data.head.ref);
core.setOutput('pr_author', pr.data.user.login);

- name: Delete triggering /preview comment
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
});

- name: Post "Preview building" comment
id: create_comment
Expand All @@ -90,10 +80,20 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `⏳ **Preview building...**`,
body: `⏳ **Preview building...**\n\ncc ${mentions}`,
});
core.setOutput('comment_id', comment.id);

- name: Delete triggering /preview comment
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
});

deploy-preview:
name: Deploy Preview to Cloudflare Pages
needs: [check-permission, notify-preview-start]
Expand All @@ -102,18 +102,17 @@ jobs:
pull-requests: write
contents: read
steps:
- name: Checkout Engine
- name: Checkout Engine (PR Code)
uses: actions/checkout@v4
with:
path: engine
repository: ThePythonLedger/Docusaurus-engine
- name: Checkout Curriculum (PR Code)
ref: ${{ needs.notify-preview-start.outputs.sha }}

- name: Checkout Curriculum
uses: actions/checkout@v4
with:
path: Curriculum
repository: ThePythonLedger/Curriculum
ref: ${{ needs.notify-preview-start.outputs.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -137,7 +136,7 @@ jobs:
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages deploy engine/build --project-name=python-ledger-preview --branch=pr-${{ needs.notify-preview-start.outputs.pr_num }}
command: pages deploy engine/build --project-name=python-ledger-preview --branch=engine-pr-${{ needs.notify-preview-start.outputs.pr_num }}

- name: Update Preview Comment with Link
uses: actions/github-script@v7
Expand All @@ -146,7 +145,7 @@ jobs:
const prNumber = ${{ needs.notify-preview-start.outputs.pr_num }};
const prAuthor = "${{ needs.notify-preview-start.outputs.pr_author }}";
const triggerUser = context.actor;
const previewUrl = `https://pr-${prNumber}.python-ledger-preview.pages.dev`;
const previewUrl = `https://engine-pr-${prNumber}.python-ledger-preview.pages.dev`;

let mentions = `@${triggerUser}`;
if (prAuthor && prAuthor !== triggerUser) {
Expand Down Expand Up @@ -184,12 +183,12 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
BRANCH_NAME="pr-${{ github.event.number }}"
BRANCH_NAME="engine-pr-${{ github.event.number }}"
PROJECT_NAME="python-ledger-preview"

echo "Deleting Cloudflare Pages branch: $BRANCH_NAME"

curl -s -X DELETE \
"https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/${PROJECT_NAME}/branches/${BRANCH_NAME}" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json"
-H "Content-Type: application/json"
Loading