Skip to content

Commit

Permalink
feat: add sync workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxity committed May 17, 2024
1 parent da59eee commit 6c6a84f
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/sync-new-releases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Sync New Releases

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
sync-new-releases:
runs-on: ubuntu-latest
steps:
- name: Compare Releases
id: compare_releases
uses: actions/github-script@v7
with:
script: |
const upstream = await github.rest.repos.getLatestRelease({
owner: 'mattermost',
repo: 'mattermost'
});
core.info(`Upstream release: ${upstream.data.tag_name}`);
const fork = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
core.info(`Fork release: ${fork.data.tag_name}`);
if (upstream.data.tag_name !== fork.data.tag_name) {
core.setOutput('new_tag', upstream.data.tag_name);
}
- name: Checkout
uses: actions/checkout@v4
if: steps.compare_releases.outputs.new_tag
with:
token: ${{ secrets.PAT }}
fetch-depth: 0

- name: Sync Branch & Tag
if: steps.compare_releases.outputs.new_tag
run: |
tag="${{ steps.compare_releases.outputs.new_tag }}"
version="${tag:1}"
major_minor="${version%.*}"
releaseBranch="release-$major_minor"
git remote add mattermost https://github.com/mattermost/mattermost.git
git fetch mattermost ${releaseBranch}
git fetch mattermost tag ${tag}
git checkout -b ${releaseBranch} --track mattermost/${releaseBranch}
git reset --hard ${tag}
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git cherry-pick da59eee80f94ef2ba9d87375abebea88261caf33
git tag ${tag} --force
git push origin ${releaseBranch} --force
git push origin ${tag} --force

0 comments on commit 6c6a84f

Please sign in to comment.