Feat/507 add citation field #2807
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: Slack-like comments | |
on: | |
issue_comment: | |
types: | |
- "created" | |
- "edited" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
approve-pr: | |
name: Approve PR | |
runs-on: ubuntu-latest | |
if: github.event.issue.pull_request | |
env: | |
admins: '["seyfeb", "christianlupus"]' | |
steps: | |
- run: |- | |
echo "Admins: $admins" | |
echo "User is permitted: ${{ contains(fromJSON(env.admins), github.event.comment.user.login) }}" | |
echo "Comment body matches /approve: ${{github.event.comment.body == '/approve'}}" | |
- uses: hmarr/auto-approve-action@v3 | |
if: >- | |
github.event.comment.body == '/approve' && | |
contains(fromJSON(env.admins), github.event.comment.user.login) | |
with: | |
github-token: ${{ secrets.COOKBOOK_BOT_TOKEN }} | |
pull-request-number: ${{ github.event.issue.number }} | |
review-message: "Automatically approved by GitHub action on behalf of `/approve`" | |
backport: | |
name: Backport PR | |
runs-on: ubuntu-latest | |
if: github.event.issue.pull_request | |
env: | |
admins: '["seyfeb", "christianlupus"]' | |
steps: | |
- name: Collect data | |
run: |- | |
echo "Admins: $admins" | |
echo "User is permitted: ${{ contains(fromJSON(env.admins), github.event.comment.user.login) }}" | |
echo "permitted_user=${{ contains(fromJSON(env.admins), github.event.comment.user.login) }}" >> "$GITHUB_OUTPUT" | |
echo "Comment body matches /backport: ${{ startsWith(github.event.comment.body, '/cb-backport')}}" | |
echo "use_backport=${{ startsWith(github.event.comment.body, '/cb-backport')}}" >> "$GITHUB_OUTPUT" | |
echo "startBackport=${{ startsWith(github.event.comment.body, '/cb-backport') && contains(fromJSON(env.admins), github.event.comment.user.login) }}" >> "$GITHUB_OUTPUT" | |
echo "number=${{ github.event.issue.number }}" >> "$GITHUB_ENV" | |
echo "$BODY" > /tmp/comment | |
id: config | |
env: | |
BODY: "${{ github.event.comment.body }}" | |
- name: Add reaction upon start | |
if: steps.config.outputs.startBackport == 'true' | |
uses: peter-evans/[email protected] | |
with: | |
token: ${{ secrets.COOKBOOK_BOT_TOKEN }} | |
repository: ${{ github.event.repository.full_name }} | |
comment-id: ${{ github.event.comment.id }} | |
reactions: "+1" | |
- name: Checkout of the app data | |
if: steps.config.outputs.startBackport == 'true' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.COOKBOOK_BOT_TOKEN }} | |
- name: Carry out the backport | |
if: steps.config.outputs.startBackport == 'true' | |
run: .github/actions/backport/backport.sh | |
env: | |
DEBUG: ${{ runner.debug }} | |
id: backport | |
- name: Create a pull request | |
if: steps.config.outputs.startBackport == 'true' | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.COOKBOOK_BOT_TOKEN }} | |
branch: ${{ steps.backport.outputs.branchName }} | |
base: ${{ steps.backport.outputs.targetBranch }} | |
title: Backport of ${{ github.event.issue.title }} | |
body: |- | |
Backport of #${{ github.event.issue.number }} | |
${{ github.event.body }} | |