favorites drag and drop #1167
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Build and Release | |
on: | |
pull_request: | |
types: [opened, synchronize, closed, ready_for_review] | |
permissions: write-all | |
jobs: | |
build: | |
if: github.event.action != 'closed' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20.x | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci --verbose | |
- name: Run build | |
run: npm run build | |
- name: Create and push release branch | |
id: create_branch | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b pr-releases/pr-${PR_NUMBER} | |
git add -f build Sources | |
git commit -m "Add build folder for PR ${PR_NUMBER}" | |
git push -u origin pr-releases/pr-${PR_NUMBER} --force | |
echo "BRANCH_NAME=pr-releases/pr-${PR_NUMBER}" >> $GITHUB_ENV | |
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Find Previous Comment | |
uses: peter-evans/find-comment@v3 | |
id: find_comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: 'Temporary Branch Update' | |
direction: last | |
- name: Create Comment Body | |
uses: actions/github-script@v7 | |
id: create_body | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const branchName = process.env.BRANCH_NAME; | |
const commitHash = process.env.COMMIT_HASH; | |
const prNumber = context.issue.number; | |
const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`; | |
const branchUrl = `${repoUrl}/tree/${branchName}`; | |
const commitUrl = `${repoUrl}/commit/${commitHash}`; | |
const commentBody = ` | |
### Temporary Branch Update | |
The temporary branch has been updated with the latest changes. Below are the details: | |
- **Branch Name**: [${branchName}](${branchUrl}) | |
- **Commit Hash**: [${commitHash}](${commitUrl}) | |
- **Install Command**: \`npm i github:duckduckgo/content-scope-scripts#${commitHash}\` | |
Please use the above install command to update to the latest version. | |
`; | |
core.setOutput('comment_body', commentBody); | |
core.setOutput('pr_number', prNumber); | |
- name: Create, or Update the Comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
body: ${{ steps.create_body.outputs.comment_body }} | |
edit-mode: replace | |
clean_up: | |
if: github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Delete release branch | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git push origin --delete pr-releases/pr-${PR_NUMBER} |