-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
95 lines (84 loc) · 2.55 KB
/
action.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Play Chess
description: 'Automate playing chess and updating move statistics in GitHub issues.'
inputs:
token:
description: 'GitHub token.'
required: true
issue_number:
description: 'The GitHub issue number where the chess move is recorded.'
required: false
default: ${{ github.event.issue.number }}
repository_name:
description: 'Name of the GitHub repository.'
required: false
default: ${{ github.repository }}
runs:
using: "composite"
steps:
- name: Checkout chess-actions repository
uses: actions/checkout@v4
with:
repository: 'rudra-iitm/chess-actions'
ref: main
path: chess-actions
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install dependencies
run: |
cd chess-actions
npm ci
shell: bash
- name: Build TypeScript
run: |
cd chess-actions
npm run build
shell: bash
- name: Process chess move
run: |
if [ -d "data" ]; then
cp -r data chess-actions/data || exit 1
fi
cd chess-actions
node dist/index.js
env:
GITHUB_TOKEN: ${{ inputs.token }}
ISSUE_NUMBER: ${{ inputs.issue_number }}
GITHUB_REPOSITORY: ${{ inputs.repository_name }}
shell: bash
- name: Cleanup
run: |
if [ -d "chess-actions/data" ]; then
cp -r chess-actions/data . || exit 1
fi
rm -rf chess-actions
shell: bash
- name: Check for changes
run: |
git add -A
changes_detected=$(git diff --cached --quiet; echo $?)
echo "::set-output name=changes_detected::$changes_detected"
shell: bash
id: changes_check
- name: Commit files
if: steps.changes_check.outputs.changes_detected != '0'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
commit_msg="Game-Issue#${{ inputs.issue_number }}-UpdatedGameStats"
git commit -a -m "$commit_msg"
shell: bash
- name: Push changes
if: steps.changes_check.outputs.changes_detected != '0'
uses: ad-m/github-push-action@master
with:
github_token: ${{ inputs.token }}
branch: ${{ github.ref }}