1+ name : Resyntax Autofixer
2+
3+ on :
4+ workflow_dispatch :
5+ schedule :
6+ - cron : " 0 0 * * 5"
7+
8+ jobs :
9+ autofix :
10+ runs-on : ubuntu-latest
11+ env :
12+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
13+ permissions :
14+ pull-requests : write
15+ contents : write
16+ steps :
17+ - name : Generate a token
18+ id : generate-token
19+ uses : actions/create-github-app-token@v1
20+ with :
21+ app-id : ${{ vars.RESYNTAX_APP_ID }}
22+ private-key : ${{ secrets.RESYNTAX_APP_PRIVATE_KEY }}
23+ - name : Get GitHub App User ID
24+ id : get-user-id
25+ run : echo "user-id=$(gh api "/users/${{ steps.generate-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
26+ env :
27+ GH_TOKEN : ${{ steps.generate-token.outputs.token }}
28+ - name : Checkout code
29+ uses : actions/checkout@v3.0.2
30+ # See https://github.com/actions/checkout/issues/118.
31+ with :
32+ fetch-depth : 0
33+ - name : Install Racket
34+ uses : Bogdanp/setup-racket@v1.9.1
35+ with :
36+ version : current
37+ packages : resyntax
38+ local_catalogs : $GITHUB_WORKSPACE
39+ dest : ' "${HOME}/racketdist-current-CS"'
40+ sudo : never
41+ - name : Register local packages
42+ run : |
43+ raco pkg install -i --auto --no-setup --skip-installed typed-racket-test
44+ raco pkg update --auto --no-setup source-syntax typed-racket-lib typed-racket-more typed-racket-compatibility typed-racket-doc typed-racket typed-racket-test
45+ - name : Install local packages
46+ run : raco setup typed typed-racket typed-racket-test typed-scheme
47+ - name : Create a new branch
48+ run : git checkout -b autofix-${{ github.run_number }}-${{ github.run_attempt }}
49+ - name : Run Resyntax
50+ run : racket -l- resyntax/cli fix --directory . --max-fixes 20 --max-modified-files 3 --output-as-commit-message >> /tmp/resyntax-output.txt
51+ - name : Create pull request
52+ uses : actions/github-script@v6.4.1
53+ with :
54+ github-token : ${{ steps.generate-token.outputs.token }}
55+ script : |
56+ const { readFile, writeFile } = require('fs/promises');
57+ const commitMessageBody = await readFile('/tmp/resyntax-output.txt', { encoding: 'utf8' });
58+ const commitMessageTitle = "Automated Resyntax fixes";
59+ const commitMessage = commitMessageTitle + "\n\n" + commitMessageBody;
60+ await writeFile('/tmp/resyntax-commit-message.txt', commitMessage);
61+ await exec.exec('git config user.name "${{ steps.generate-token.outputs.app-slug }}[bot]"');
62+ await exec.exec('git config user.email "${{ steps.get-user-id.outputs.user-id }}+${{ steps.generate-token.outputs.app-slug }}[bot]@users.noreply.github.com"');
63+ await exec.exec('git commit --all --file=/tmp/resyntax-commit-message.txt');
64+ await exec.exec('git push --set-upstream origin autofix-${{ github.run_number }}-${{ github.run_attempt }}');
65+ await github.rest.pulls.create({
66+ owner: context.repo.owner,
67+ repo: context.repo.repo,
68+ title: commitMessageTitle,
69+ head: "autofix-${{ github.run_number }}-${{ github.run_attempt }}",
70+ base: "master",
71+ body: commitMessageBody,
72+ maintainer_can_modify: true,
73+ });
0 commit comments