Nixpkgs update #47
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: Nixpkgs update | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
update: | |
timeout-minutes: 600 | |
name: Update nixpkgs | |
runs-on: ubuntu-latest | |
outputs: | |
branch_name: '${{ steps.branch.outputs.branch }}' | |
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 "niv update nixpkgs" | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
- id: branch | |
name: set branch name | |
run: echo ::set-output name=branch::autoupdate-nixpkgs-$(date '+%d-%m-%y') | |
- name: Install packages | |
run: sudo apt-get install jq | |
- name: Push if updated | |
run: | | |
git config --global user.name $GITHUB_ACTOR | |
git config --global user.email "action@github.com" | |
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-nixpkgs-*" | awk -F'/' '{if($3 != "") print $3}'`;do | |
git push origin --delete ${branch} -q | |
done | |
rev=$(jq -r .nixpkgs.rev < nix/sources.json) | |
git checkout -b $BRANCH_NAME -q | |
git add -A | |
git commit -m "nixpkgs: update to ${rev}" -q | |
git push origin $BRANCH_NAME | |
else | |
exit 1 | |
fi | |
env: | |
BRANCH_NAME: '${{ steps.branch.outputs.branch }}' | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
build: | |
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}}' | |
- 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 | |
nix-build -A terraform-providers | |
env: | |
NIXPKGS_ALLOW_UNFREE: 1 | |
commit: | |
needs: | |
- build | |
- update | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: '${{needs.update.outputs.branch_name}}' | |
fetch-depth: 2 | |
- name: open pr | |
run: | | |
git config --global user.name $GITHUB_ACTOR | |
git config --global user.email "action@github.com" | |
hub pull-request -m "nixpkgs: update" | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |