-
Notifications
You must be signed in to change notification settings - Fork 12
175 lines (169 loc) · 6.12 KB
/
copy_firmware.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
163
164
165
166
167
168
169
170
171
172
173
174
175
name: copy_firmware
on:
repository_dispatch:
workflow_dispatch:
push:
branches: copy_firmware
paths:
- 'trigger.txt'
# Ensures that only one deploy task per branch/environment will run at a time.
concurrency:
group: environment-${{ github.ref }}
cancel-in-progress: false
jobs:
empty_branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: firmware
- name: Create new empty firmware branch
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git switch --orphan new_branch # create empty branch
git commit --allow-empty -m "Initial commit"
git push -u origin new_branch # push empty branch in repo
git switch firmware
git reset --hard new_branch # reset firmware branch
git push origin firmware -f
git push origin --delete new_branch # delete empty_branch
release_restore:
needs: empty_branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.MASTER_ACCESS_TOKEN }}
ref: firmware
- name: Merge branch main into branch firmware
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git remote add -f mrg_main "https://github.com/Jason2866/Tasmota-specials.git" --track main
git switch -c work
git merge mrg_main/main --allow-unrelated-histories
- name: Push into branch firmware
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GITHUB_TOKEN}}
branch: 'firmware'
- name: Download artifact "special_firmwares"
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: Build_special_firmware.yml
repo: Jason2866/Tasmota-build
name: special*
name_is_regexp: true
- name: Display downloaded artifact files
run: |
ls -R ./special_firmware
- name: Move files back
run: |
mkdir -p ./firmware/map
mkdir -p ./firmware/tasmota/other/
mkdir -p ./firmware/tasmota32/other/
cp ./special_firmware/map/* ./firmware/map
mv ./special_firmware/firmware/tasmota32* ./firmware/tasmota32/other/
mv ./special_firmware/firmware/tasmota* ./firmware/tasmota/other/
rm -rf ./special_firmware
rm tag_latest.txt 2> /dev/null || echo > /dev/null
- name: Build Tag and commit message
run: |
tas_com_tmp1=$(curl -s "https://api.github.com/repos/arendst/tasmota/commits/development" | jq -r '.sha')
tas_com_tmp="Based on https://github.com/arendst/Tasmota/commit/${tas_com_tmp1}"
tag_name_tmp="$(date -I).d.$tas_com_tmp1"
rm release-info.txt 2> /dev/null || echo > /dev/null
echo "$tas_com_tmp" >> release-info.txt
echo "$tag_name_tmp" >> tag_latest.txt
echo "$tag_name_tmp" >> tag.txt
echo "tas_com=$tas_com_tmp" >> $GITHUB_ENV
echo "tag_name=$tag_name_tmp" >> $GITHUB_ENV
- name: Display structure of updated content
run: |
ls -R
- name: Update Manifest files
run: |
mkdir manifest_release
python genManifest.py
python genManifestWithFeatureas.py
python genManifestRelease.py
#python genManifestsForAllReleases.py
- name: Release special firmwares
uses: jason2866/[email protected]
with:
tag_name: ${{ env.tag_name }}
body_path: release-info.txt
prerelease: true
files: |
tag_latest.txt
tag.txt
manifests_release.json
all_manifests_in_releases.json.gz
manifest_release/*
firmware/map/*
firmware/tasmota/other/*
firmware/tasmota32/other/*
env:
GITHUB_TOKEN: ${{ secrets.MASTER_ACCESS_TOKEN }}
- name: Remove not needed files stored in repo
run: |
rm manifests_release.json
rm -rf manifest_release
- name: Commit everything
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add -A
git commit --allow-empty -m "${{ env.tas_com }}"
- name: Push new content in branch firmware
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GITHUB_TOKEN}}
branch: 'firmware'
- name: Push changed tag files in branch main
uses: Jason2866/copy_file_to_another_repo_action@multi_files
env:
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
with:
source_file: "tag.txt,tag_latest.txt"
destination_repo: 'Jason2866/Tasmota-specials'
destination_branch: 'main'
commit_message: "tag updated"
user_email: '41898282+github-actions[bot]@users.noreply.github.com'
user_name: 'github-actions[bot]'
- name: Checkout branch firmware for prepare deploy
uses: actions/checkout@v3
with:
ref: firmware
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: '.'
deploy:
needs: release_restore
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
start_workflow:
needs: release_restore
runs-on: ubuntu-latest
steps:
- name: Dispatch workflow in repo Tasmota/install
run: |
curl -X POST https://api.github.com/repos/Tasmota/install/actions/workflows/devel_release_firmware.yml/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.MASTER_ACCESS_TOKEN }} \
--data '{"ref": "gh_actions"}'