-
-
Notifications
You must be signed in to change notification settings - Fork 8
162 lines (143 loc) · 5.9 KB
/
update_libraries.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Update library zip and submodules
on:
push:
branches:
- master
schedule:
- cron: '0 1 * * 0'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
pull-requests: write # 'write' access to pull requests
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
# check out the repo
- uses: actions/checkout@v4
with:
ref: master
submodules: false
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install python dependencies
run: |
pip install --upgrade --upgrade-strategy only-if-needed -r requirements.txt
- name: Install submodules
run: |
git config --global user.email "[email protected]"
git config --global user.name "SRGDamia1"
git config --global push.default simple
git submodule init
git status
git submodule update --remote --recursive
git status
- name: Queue changes in submodules for commit
run: |
git add -A
git status
- name: Create submodule_status file
run: |
echo "::debug::Creating a new submodule status file.\n"
git submodule status --recursive > submodule_status.txt
git status
echo "::debug::Checking for changes in the submodule status file."
git diff HEAD -- submodule_status.txt
echo "::debug::Setting a new environment variable"
echo "submod_updated=$(git diff --name-only HEAD -- submodule_status.txt)" >> $GITHUB_ENV
echo "::debug::submodules updated = $submod_updated"
- name: Check env variable
run: echo submodules updated = $submod_updated
- name: Zip submodules
if: ${{ env.submod_updated }}
run: |
echo "::debug::Archiving Submodules."
git-archive-all --force-submodules libraries.zip
git status
- name: Remove git folders and files from zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Deleting extra files to decrease size of zip"
echo "::debug::Removing Git folders"
zip -d -q libraries "*/.gitattributes" "*/.gitignore" "*/.gitmodules" "*/.github/*" "*.sh" "*/Doxyfile" "*/.travis.yml"
- name: Remove pdfs from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing other pdfs"
zip -d -q libraries "*/doc/*.pdf"
- name: Remove TinyGSM extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing TinyGSM extras"
zip -d -q libraries "*/TinyGSM/extras/*"
- name: Remove YosemitechModbus extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing YosemitechModbus extras"
zip -d -q libraries "*/YosemitechModbus/doc/*"
- name: Remove SDFat extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing SDFat extras"
zip -d -q libraries "*/SdFat/extras/*"
- name: Queue zip
if: ${{ env.submod_updated }}
run: |
echo "::debug::Queueing changes for commit"
git add -A;
echo "::debug::Git status"
git status
echo "::debug::Setting a new environment variable"
git diff --name-only HEAD -- libraries.zip
echo "is_changed=$(git diff --name-only HEAD -- libraries.zip)" >> $GITHUB_ENV
echo "::debug::zip changed = $is_changed"
- name: Check env variable
run: echo zip changed = $is_changed
- name: Commit changes to master
if: ${{ env.is_changed }}
run: |
git commit -m "Updated submodules and zip via Github Action (${{ github.workflow }} ${{ github.event_name }} ${{ github.run_number }} ) [ci skip]";
- name: Push changes to master
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
- name: Checkout platformio branch
run: |
echo "::debug::Stashing changes before switching branches"
git stash
echo "::debug::Checking out the platformio branch"
git checkout platformio
git status
echo "::debug::Checking out the library manifest from the master branch"
git checkout master -- library.json
git status
echo "::debug::Queueing changes to the manifest for commit"
git add library.json
git status
echo "::debug::Setting a new environment variable"
git diff --name-only HEAD -- library.json
echo "manifest_changed=$(git diff --name-only HEAD -- library.json)" >> $GITHUB_ENV
echo "::debug::manifest changed = $manifest_changed"
- name: Check env variable
run: echo manifest changed = $manifest_changed
- name: Commit changes to platformio branch
if: ${{ env.manifest_changed }}
run: git commit -m "Updated library.json via Github Action (${{ github.workflow }} ${{ github.event_name }} ${{ github.run_number }} ) [ci skip]";
- name: Push to platformio branch
if: ${{ env.manifest_changed }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: platformio