Autoupdate other derivations #193
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: Autoupdate other derivations | |
on: | |
schedule: | |
- cron: '0 5 * * 1,3,5' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
update: | |
timeout-minutes: 600 | |
name: Update Toolbox components | |
runs-on: ubuntu-latest | |
outputs: | |
branch: '${{ steps.mr.outputs.branch }}' | |
updates: '${{ steps.mr.outputs.updates }}' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: cachix/install-nix-action@v25 | |
- name: Setup binary cache | |
uses: cachix/cachix-action@v14 | |
with: | |
name: toolbox | |
skipPush: true | |
- name: Check for updates | |
run : | | |
nix-shell --command autoupdate/update.py | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
SOURCE_FILTER: '(?!terraform.*)' | |
- name: Create MR | |
id: mr | |
run: | | |
git config --global user.name $GITHUB_ACTOR | |
git config --global user.email "[email protected]" | |
if [ `git status --porcelain=v2 | wc -l` -ne 0 ]; then | |
echo "Changes detected ! Creating pull request..." | |
git fetch --all | |
for branch in `git branch --list -a "*autoupdate-packages-*" | awk -F'/' '{if($3 != "") print $3}'`;do | |
git push origin --delete ${branch} -q | |
done | |
BRANCH_NAME=autoupdate-packages-$(date '+%d-%m-%y') | |
git checkout -b $BRANCH_NAME -q | |
git add -A | |
git commit -m "autoupdate: $(date '+%d-%m-%y')" -q | |
mv changes.md changes_wip.md | |
git add changes_wip.md | |
git commit -m "add update changelog" | |
git push origin $BRANCH_NAME | |
echo ::set-output name=updates::true | |
echo ::set-output name=branch::$BRANCH_NAME | |
else | |
echo ::set-output name=updates::false | |
fi | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
build: | |
if: ${{ needs.update.outputs.updates == 'true' }} | |
needs: | |
- update | |
timeout-minutes: 600 | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: '${{ needs.update.outputs.branch }}' | |
- name: Install Nix | |
uses: cachix/install-nix-action@v25 | |
- name: Setup binary cache | |
uses: cachix/cachix-action@v14 | |
with: | |
name: toolbox | |
skipPush: true | |
- name: Build packages | |
run: | | |
nix-build | |
env: | |
NIXPKGS_ALLOW_UNFREE: 1 | |
commit: | |
needs: | |
- build | |
- update | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: '${{ needs.update.outputs.branch }}' | |
fetch-depth: 2 | |
- name: open pr | |
run: | | |
git config --global user.name $GITHUB_ACTOR | |
git config --global user.email "[email protected]" | |
cp changes_wip.md changes.md | |
git reset --hard "HEAD^" | |
git push --force | |
hub pull-request -F changes.md | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |