-
-
Notifications
You must be signed in to change notification settings - Fork 7
74 lines (66 loc) · 2.64 KB
/
update-submodule.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
# This action creates a PR on the freeCodeCamp repo to update the i18n-curriculum submodule.
name: Update i18n-curriculum Submodule
on:
workflow_dispatch:
push:
branches:
- main
env:
GITHUB_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/'
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }}
jobs:
check-pr-title:
runs-on: ubuntu-22.04
outputs:
run_update: ${{ steps.check.outputs.run_update }}
steps:
- name: Check PR Title
id: check
run: |
pr_number=$(echo $GITHUB_REF | awk -F/ '{print $3}')
author=$(gh pr view $pr_number --json user.login -q '.user.login')
if [ "$author" == "moT01" ]; then
echo "::set-output name=run_update::true"
else
echo "::set-output name=run_update::false"
fi
update-i18n-curriculum-submodule:
name: Update i18n-curriculum Submodule
needs: check-pr-title
runs-on: ubuntu-22.04
if: needs.check-pr-title.outputs.run_update == 'true'
steps:
- name: Checkout Source Files
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# Todo: Change to fcc repo after this is transferred
repository: 'moT01/fcc'
token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
submodules: true
- name: Ensure correct submodule path and initialization
run: |
git submodule sync
git submodule update --init --recursive
- name: Update submodule
run: |
git config --global user.email "${{ secrets.ACTIONS_CAMPERBOT_EMAIL }}"
git config --global user.name "camperbot"
git checkout -b chore/update-i18n-curriculum-submodule
git submodule update --remote i18n-curriculum
cd i18n-curriculum && SUBMODULE_HASH=$(git rev-parse --short HEAD) && cd ..
git add .
git commit -m "chore(curriculum): Update i18n-curriculum submodule to $SUBMODULE_HASH"
git push -u origin chore/update-i18n-curriculum-submodule -f
- name: Create PR
uses: freecodecamp/crowdin-action@main
env:
PLUGIN: 'pull-request'
GH_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
BRANCH: 'chore/update-i18n-curriculum-submodule'
# Todo: Change to fcc repo after this is transferred
REPOSITORY: 'moT01/fcc'
BASE: 'main'
TITLE: 'chore(i18n,learn): update i18n-curriculum submodule'
BODY: 'This PR was opened auto-magically by camperbot.'