Auto Pull Request #261
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: Auto Pull Request | |
on: | |
schedule: | |
- cron: "0 */2 * * *" | |
- cron: "0 */6 * * *" | |
permissions: write-all | |
jobs: | |
auto-pull-request: | |
if: ${{ github.event.schedule == '0 */2 * * *' }} | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: nixos-unstable | |
- name: Setup git | |
run: | | |
git config --global user.name 'little fmway' | |
git config --global user.email 'fm18lv@gmail.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
- name: Refresh Git Remote | |
run: git fetch origin | |
# - name: Refresh Your Head | |
# run: | | |
# git rebase origin/master nixos-unstable | |
# git push origin nixos-unstable --force | |
- name: Check if PR exists | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
prs=$(gh pr list \ | |
--repo "$GITHUB_REPOSITORY" \ | |
--head 'nixos-unstable' \ | |
--base 'master' \ | |
--json title \ | |
--jq 'length') | |
count_commit=$(git rev-list --left-right --count origin/nixos-unstable...origin/master | awk '{print $1}') | |
if (( prs > 0 )) || (( count_commit < 1 )); then | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create Pull Request | |
if: '!steps.check.outputs.skip' | |
env: | |
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
gh pr create --title "Merge From nixos-unstable" --body "" -l "automated" | |
update-stubby: | |
if: ${{ github.event.schedule == '0 */6 * * *' }} | |
runs-on: [ "ubuntu-latest" ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup git | |
run: | | |
git config --global user.name 'little fmway' | |
git config --global user.email 'fm18lv@gmail.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
- uses: DeterminateSystems/nix-installer-action@main | |
with: | |
github-token: ${{ secrets.GH_TOKEN }} | |
extra-conf: experimental-features = nix-command flakes auto-allocate-uids configurable-impure-env pipe-operators | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
with: | |
use-flakehub: false | |
- run: nix run .#updateStubbyCert | |
- name: Check Updates | |
id: check | |
env: | |
GITHUB_TOKEN: ${{secrets.GH_TOKEN}} | |
run: | | |
if [ -n "$(git status --short)" ]; then | |
git add -A | |
git commit -m "chore(systems): update certs dns" | |
git checkout -B stubby-updater | |
git push origin stubby-updater | |
if [ -z "$(git diff origin/stubby-updater origin/master)" ]; then | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
fi | |
else | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Pull Request | |
if: '!steps.check.outputs.skip' | |
env: | |
GITHUB_TOKEN: ${{secrets.GH_TOKEN}} | |
run: | | |
gh pr create --title "chore(system): update certs dns" --body "" -l "automated" -l "dependencies" --head stubby-updater --base master |