Skip to content

feat: Brand and impact pages #54

feat: Brand and impact pages

feat: Brand and impact pages #54

Workflow file for this run

name: Comment live URL on merged publish PR
on:
pull_request:
types: [closed]
branches: [main]
jobs:
post-live-url:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'publish/issue-')
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Find content file and build live URL
id: detect
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
...context.repo,
pull_number: context.payload.pull_request.number,
});
const contentFile = files.find(f =>
/^src\/content\/(apps|mechanisms|research|case-studies|campaigns)\/.+\.md$/.test(f.filename)
);
if (!contentFile) return;
const [, type, slug] = contentFile.filename.match(
/^src\/content\/(apps|mechanisms|research|case-studies|campaigns)\/(.+)\.md$/
);
core.setOutput('url', `https://gitcoin.co/${type}/${slug}`);
- name: Comment on PR and issue
if: steps.detect.outputs.url
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.detect.outputs.url }}';
const body = `Live at: ${url}`;
// Comment on the PR
await github.rest.issues.createComment({
...context.repo,
issue_number: context.payload.pull_request.number,
body,
});
// Comment on the original issue (encoded in the branch name)
const branch = context.payload.pull_request.head.ref;
const issueMatch = branch.match(/publish\/issue-(\d+)/);
if (issueMatch) {
await github.rest.issues.createComment({
...context.repo,
issue_number: parseInt(issueMatch[1]),
body,
});
}