mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-16 11:36:55 +00:00
add mediamtx-rpicamera automatic updater (#3893)
This commit is contained in:
parent
2453284114
commit
7c4849eb1e
87
.github/workflows/bump_rpicamera.yml
vendored
Normal file
87
.github/workflows/bump_rpicamera.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
name: bump_rpicamera
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '4 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
bump_rpicamera:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: >
|
||||
git config user.name mediamtx-bot
|
||||
&& git config user.email bot@mediamtx
|
||||
&& ((git checkout deps/mediamtx-rpicamera && git rebase ${GITHUB_REF_NAME}) || git checkout -b deps/mediamtx-rpicamera)
|
||||
|
||||
- uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
|
||||
// get last tag
|
||||
let curTag = null;
|
||||
for (let i = 1; i < 20; i++) {
|
||||
const tags = await github.rest.repos.listTags({
|
||||
owner: 'bluenviron',
|
||||
repo: 'mediamtx-rpicamera',
|
||||
page: i,
|
||||
});
|
||||
for (const tag of tags.data) {
|
||||
curTag = tag;
|
||||
break;
|
||||
}
|
||||
if (curTag !== null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// write version to disk
|
||||
await fs.writeFile('internal/staticsources/rpicamera/mtxrpicamdownloader/VERSION', curRelease['tag_name'] + '\n', 'utf-8');
|
||||
|
||||
// make version available to next steps
|
||||
core.exportVariable('VERSION', curTag.name);
|
||||
|
||||
- id: check_repo
|
||||
run: >
|
||||
test -n "$(git status --porcelain)" && echo "update=1" >> "$GITHUB_OUTPUT" || echo "update=0" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- if: ${{ steps.check_repo.outputs.update == '1' }}
|
||||
run: >
|
||||
git reset ${GITHUB_REF_NAME}
|
||||
&& git add .
|
||||
&& git commit -m "bump mediamtx-rpicamera to ${VERSION}"
|
||||
&& git push --set-upstream origin deps/mediamtx-rpicamera --force
|
||||
|
||||
- if: ${{ steps.check_repo.outputs.update == '1' }}
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const prs = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
head: `${context.repo.owner}:deps/mediamtx-rpicamera`,
|
||||
state: 'open',
|
||||
});
|
||||
|
||||
if (prs.data.length == 0) {
|
||||
await github.rest.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
head: 'deps/mediamtx-rpicamera',
|
||||
base: context.ref.slice('refs/heads/'.length),
|
||||
title: `bump mediamtx-rpicamera to ${process.env.VERSION}`,
|
||||
});
|
||||
} else {
|
||||
github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prs.data[0].number,
|
||||
title: `bump mediamtx-rpicamera to ${process.env.VERSION}`,
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user