copy_firmware #1756
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
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@v4 | |
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@v3 | |
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/action-gh-release@v1.3 | |
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@v4 | |
with: | |
ref: firmware | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
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@v4 | |
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"}' |