klipper-dgus/.github/workflows/upstream-sync.yml

73 lines
2.2 KiB
YAML

name: Upstream sync
on:
schedule:
- cron: '0 0 * * 6'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Merge changes
uses: actions/github-script@v3
with:
github-token: ${{ secrets.TOKEN }}
script: |
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms))
const { data: pullRequest } = await github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Upstream sync",
head: "KevinOConnor:master",
base: "snapshot",
maintainer_can_modify: false
})
await timeout(3000)
await github.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequest.number,
commit_title: "Merge upstream changes",
merge_method: "merge"
})
await timeout(3000)
- name: Checkout snapshot
uses: actions/checkout@v2
with:
token: ${{ secrets.TOKEN }}
ref: snapshot
- name: Generate tag parameters
id: params
run: |
echo "::set-output name=tagname::snapshot-$(date +'%y%m%d')"
echo "::set-output name=tagsha::$(git log -1 --format=%H)"
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ secrets.TOKEN }}
script: |
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms))
const { data: tag } = await github.git.createTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: "${{ steps.params.outputs.tagname }}",
message: "/!\\ This is an automated, untested release. Use at your own risk /!\\",
object: "${{ steps.params.outputs.tagsha }}",
type: "commit"
})
await timeout(3000)
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tag.tag}`,
sha: `${tag.sha}`
})