.github/workflows/zen-browser-sync.yml #7478
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
# Controls when the workflow will run | |
on: | |
# Trigger the workflow on each push | |
push: | |
# Schedule the workflow to run periodically (every 10 minutes) | |
schedule: | |
- cron: "*/10 * * * *" | |
# A workflow run consists of one or more jobs | |
jobs: | |
# This workflow includes a single job named "build" | |
build: | |
# Specify the type of runner to execute the job | |
runs-on: ubuntu-latest | |
# Sequence of tasks to be executed in the job | |
steps: | |
# Check out the repository to the GitHub Actions workspace | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
with: | |
ref: "master" | |
# Configure Git with a bot's identity for committing changes | |
- name: Configure Git | |
run: | | |
git config --local user.name "Bot" | |
git config --local user.email "[email protected]" | |
# Update the zen-browser.spec file with the latest version information | |
- name: Update zen-browser.spec | |
id: update_zen_browser_spec | |
run: | | |
# Fetch the latest release version from the Zen Browser GitHub API | |
ZEN_VER=$(curl -s https://api.github.com/repos/zen-browser/desktop/releases | jq -r 'first(.[].tag_name | select(test("^[0-9]")))') | |
ZEN_VER_SPEC=$(echo $ZEN_VER | sed 's@-@.@g') | |
OLD_VER=$(grep '^Version:' /home/runner/work/copr/copr/zen-browser/zen-browser.spec | awk '{print $2}') | |
# Replace dashes in version with dots for compatibility | |
# Update version fields in the .spec files | |
sed -i '0,/Version:.*/s//Version: '$ZEN_VER_SPEC'/' /home/runner/work/copr/copr/zen-browser/zen-browser.spec | |
sed -i '0,/Version:.*/s//Version: '$ZEN_VER_SPEC'/' /home/runner/work/copr/copr/zen-browser/zen-browser-arm.spec | |
# Update URLs in the .spec files to point to the new release | |
sed -i 's@https://github.com/zen-browser/desktop/releases/download/.*@https://github.com/zen-browser/desktop/releases/download/'$ZEN_VER'/zen.linux-x86_64.tar.xz@g' /home/runner/work/copr/copr/zen-browser/zen-browser.spec | |
sed -i 's@https://github.com/zen-browser/desktop/releases/download/.*@https://github.com/zen-browser/desktop/releases/download/'$ZEN_VER'/zen.linux-aarch64.tar.xz@g' /home/runner/work/copr/copr/zen-browser/zen-browser-arm.spec | |
if [ "$ZEN_VER_SPEC" != "$OLD_VER" ]; then | |
echo "::set-output name=version_changed::true" | |
else | |
echo "::set-output name=version_changed::false" | |
fi | |
- name: update-zen-browser-twilight-spec | |
id: update_twilight | |
run: | | |
ZEN_VER_TWILIGHT=$(curl -s https://api.github.com/repos/zen-browser/desktop/releases | jq -r '[.[] | select(.prerelease == true)][0].id') | |
OLD_VER=$(grep '^Version:' /home/runner/work/copr/copr/zen-browser/zen-twilight.spec | awk '{print $2}') | |
sed -i '0,/Version:.*/s//Version: '$ZEN_VER_TWILIGHT'/' /home/runner/work/copr/copr/zen-browser/zen-twilight.spec | |
sed -i '0,/Version:.*/s//Version: '$ZEN_VER_TWILIGHT'/' /home/runner/work/copr/copr/zen-browser/zen-twilight-arm.spec | |
if [ "$ZEN_VER_TWILIGHT" != "$OLD_VER" ]; then | |
echo "::set-output name=twilight_version_changed::true" | |
else | |
echo "::set-output name=twilight_version_changed::false" | |
fi | |
# Push changes back to the repository if there are updates | |
- name: Push changes to the repository | |
run: | | |
git config pull.rebase true | |
git add . | |
# Commit changes only if there are any | |
git diff-index --quiet HEAD || git commit -m "chore(zen-browser): Sync Zen version" | |
git push | |
- name: Trigger webhook | |
if: steps.update_zen_browser_spec.outputs.version_changed == 'true' | |
run: | | |
curl -X POST ${{ secrets.ZEN_BROWSER_WEBHOOK }} | |
curl -X POST ${{ secrets.ZEN_BROWSER_AVX2_WEBHOOK }} | |
curl -X POST ${{ secrets.ZEN_BROWSER_ARM_WEBHOOK }} | |
- name: Trigger twilight webhook | |
if: steps.update_twilight.outputs.twilight_version_changed == 'true' | |
run: | | |
curl -X POST ${{ secrets.ZEN_TWILIGHT_WEBHOOK }} | |
curl -X POST ${{ secrets.ZEN_TWILIGHT_AVX2_WEBHOOK }} | |
curl -X POST ${{ secrets.ZEN_TWILIGHT_ARM_WEBHOOK }} |