This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
Flox channel progression #507
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: "Flox channel progression" | |
on: | |
workflow_dispatch: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# Run script every day at 8 UTC | |
- cron: '01 8 * * *' | |
jobs: | |
update-guard: | |
runs-on: ubuntu-latest | |
outputs: | |
run: ${{steps.guard.outputs.run}} | |
steps: | |
- name: Check whether to update | |
id: guard | |
run: | | |
dow=$(date +%u) | |
# Do nothing on a Thursday, Friday, or Sunday. | |
if [ $dow -eq 4 -o $dow -eq 5 -o $dow -eq 7 ] | |
then | |
echo '::notice title=Skip Update::No update performed on Thursday, Friday, or Sunday' | |
# set empty output so github can read the variable | |
echo "run=false" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
# on any other day set guard to true | |
echo "run=true" >> $GITHUB_OUTPUT | |
flox-channels: | |
needs: [update-guard] | |
if: github.repository_owner == 'flox' && fromJSON(needs.update-guard.outputs.run) | |
env: | |
GH_TOKEN: ${{ secrets.GIT_TOKEN }} | |
runs-on: ubuntu-latest | |
# TODO: implement configurable merge based on matrix | |
name: "Periodic pull from upstream" | |
steps: | |
- name: Configure Git Env | |
run: | | |
# gh automatically sets the `upstream` remote to github:NixOS/nixpkgs | |
gh repo clone flox/nixpkgs ./ | |
gh auth setup-git | |
git config user.email "[email protected]" | |
git config user.name "Flox Nixpkgs Updater" | |
git config checkout.defaultRemote origin | |
# gh configures the `upstream` repo to only contain the current branch, reconfigure to fetch all | |
git remote set-branches upstream '*' | |
git fetch upstream | |
- name: run update routine | |
run: | | |
set -e | |
# Today's date in YYYYMMDD format. | |
today=$(date +%Y%m%d) | |
# Day of week (1-7) | |
dow=$(date +%u) | |
# Running list of tags to be pushed. | |
tags="" | |
branches="" | |
if [ $dow -eq 6 ] | |
then | |
dom=$(date +%e) | |
if [ $dom -le 7 ] | |
then | |
echo '::group::reset staging->stable' | |
# On first Saturday of the month, reset staging->stable. | |
git checkout stable | |
git tag stable.$today | |
tags="$tags stable.$today" | |
git reset --hard origin/staging | |
branches="$branches stable" | |
echo '::notice title=Promote Stable::Scheduled update of "stable" channel (staging->stable)' | |
echo '::endgroup::' | |
fi | |
# Every Saturday, reset unstable->staging. | |
echo '::group::reset unstable->staging' | |
git checkout staging | |
git tag staging.$today | |
tags="$tags staging.$today" | |
git reset --hard origin/unstable | |
branches="$branches staging" | |
echo '::notice title=Promote Staging::Scheduled update of "staging" channel (unstable->staging)' | |
echo '::endgroup::' | |
elif [ $dow -le 3 ] | |
then | |
# Rebase against upstream Monday-Wednesday only. | |
echo '::group::rebase against upstream' | |
git checkout unstable | |
git tag unstable.$today | |
tags="$tags unstable.$today" | |
git rebase upstream/nixos-unstable | |
branches="$branches unstable" | |
echo '::notice title=Promote Unstable::Scheduled update of "unstable" channel (rebse onto nixpkgs/nixos-unstable)' | |
echo '::endgroup::' | |
fi | |
echo "::notice title=Summary::New tags: $tags\nUpdates Branch(es): $branches" | |
git push origin -f --atomic $branches $tags | |
- name: Comment on failure | |
uses: peter-evans/create-or-update-comment@v2 | |
if: ${{ failure() }} | |
with: | |
repository: flox/product | |
issue-number: 272 | |
token: ${{ secrets.NIX_GIT_TOKEN }} | |
body: | | |
Periodic update has [failed](https://github.com/flox/nixpkgs-flox/actions/runs/${{ github.run_id }}). | |
@flox/internal |