-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (40 loc) · 1.58 KB
/
contribute.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Contribute Exercises
on:
issues:
types: [opened]
jobs:
make_contrib_pr:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'contributed exercise')
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Add Exercise
id: exercise
run: |
git config --global user.name 'Contributor Bot'
git config --global user.email 'contrib-bot@netsblox.org'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
echo '${{ github.event.issue.body }}' > exercise.json
deno run --allow-read --allow-write --allow-net utils/create-exercise-from-issue.ts exercise.json
rm exercise.json
echo "BRANCH_NAME=contrib-$(echo "${{ github.event.issue.title }}" | sed 's/New Exercise://' | sed 's/\(.*\)/\L\1/' | sed 's/[^a-z]\+/-/g' | sed 's/^-\+//' | sed 's/-\+$//')" >> $GITHUB_OUTPUT
echo "BODY=Closes #${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: cd website && npm i
- run: node utils/build-library/index.js
- name: Push changes
uses: peter-evans/create-pull-request@v5
with:
title: ${{ github.event.issue.title }}
body: ${{ steps.exercise.outputs.BODY }}
commit-message: ${{ github.event.issue.title }}
branch: ${{ steps.exercise.outputs.BRANCH_NAME }}