Workflow file for this run
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: Update from Upstream | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
push: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: fetch latest release tag from upstream repo | |
id: fetch_release | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const owner = 'MixinNetwork'; | |
const repo = 'flutter-app'; | |
const { data: latestRelease } = await github.rest.repos.getLatestRelease({owner, repo}); | |
core.setOutput('tag_name', latestRelease.tag_name); | |
- name: check has upgrade | |
id: check_upgrade | |
run: | | |
current_version=$(grep -oP "(?<=https://github.com/MixinNetwork/flutter-app/releases/download/).*(?=/mixin_desktop_linux_amd64_portable.tar.gz)" one.mixin.messenger.yml) | |
echo "current version: $current_version, remote version: ${{ steps.fetch_release.outputs.tag_name }}" | |
if [ "$current_version" != "${{ steps.fetch_release.outputs.tag_name }}" ]; then | |
echo "new version available" | |
echo "new_version=${{ steps.fetch_release.outputs.tag_name }}" >> $GITHUB_ENV | |
else | |
echo "no new version available" | |
exit 0 | |
fi | |
- name: Update version | |
if: env.new_version | |
run: | | |
sed -i "s|https://github.com/MixinNetwork/flutter-app/releases/download/.*/mixin_desktop_linux_amd64_portable.tar.gz|https://github.com/MixinNetwork/flutter-app/releases/download/${{ steps.fetch_release.outputs.tag_name }}/mixin_desktop_linux_amd64_portable.tar.gz|" one.mixin.messenger.yml | |
- name: Commit changes | |
if: env.new_version | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git add one.mixin.messenger.yml | |
git commit -m "Update to version ${{ steps.fetch_release.outputs.tag_name }}" | |
git push --set-upstream origin update-version-${{ steps.fetch_release.outputs.tag_name }} | |
- name: Create Pull Request | |
if: env.new_version | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Update to version ${{ steps.fetch_release.outputs.tag_name }} | |
branch: update-version-${{ steps.fetch_release.outputs.tag_name }} | |
title: Update to version ${{ steps.fetch_release.outputs.tag_name }} | |
body: This PR updates the version to ${{ steps.fetch_release.outputs.tag_name }}. |