Skip to content

Commit

Permalink
Use reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Dec 6, 2022
1 parent 0ca1516 commit 304c0d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 130 deletions.
65 changes: 4 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,6 @@
name: Build and test flake outputs
on:
push:
workflow_call:
inputs:
branch:
description: Branch name to build on
default: ''
required: false
type: string
name: Build and test
on: [ push ]

jobs:
nix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
system:
- x86_64
nix-command:
- flake check
- eval .#apps.$_system.nixos-install.program
- eval .#apps.$_system.setup.program

include:
- nix-command: develop
system: x86_64

- nix-command: build .#homeConfigurations."christian@non-nixos-vm".activationPackage
system: x86_64

- nix-command: build .#homeConfigurations."demo@non-nixos-vm".activationPackage
system: x86_64

- nix-command: build .#nixosConfigurations.nixos-vm.config.system.build.toplevel
system: x86_64

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}

- name: Install nix
uses: cachix/install-nix-action@v18

- uses: cachix/cachix-action@v12
with:
name: christianharke
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build command (x86_64)
if: matrix.system == 'x86_64'
env:
_system: ${{ matrix.system }}-linux
run: |
nix \
--verbose \
--log-format bar-with-logs \
--keep-going \
--show-trace \
${{ matrix.nix-command }}
nix-ci:
uses: christianharke/flake-commons/.github/workflows/nix-ci.yml@main
72 changes: 3 additions & 69 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,7 @@ on:
- cron: 0 0 * * *

jobs:
update:
runs-on: ubuntu-latest

outputs:
branch: ${{ steps.branch.outputs.name }}
update_available: ${{ steps.commit.outputs.changes_detected }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install nix
uses: cachix/install-nix-action@v18

- uses: cachix/cachix-action@v12
with:
name: christianharke
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Update inputs
run: nix flake update

- name: Set branch name output
id: branch
run: echo "name=ci/automatic-update-$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT

- name: Create branch locally
run: git switch -c ${{ steps.branch.outputs.name }}

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
id: commit
with:
commit_author: Christian Harke <[email protected]>
commit_message: "flake.inputs: automatic update"
branch: ${{ steps.branch.outputs.name }}
push_options: --force

build:
uses: christianharke/nixcfg/.github/workflows/ci.yml@master
needs: update
if: needs.update.outputs.update_available == 'true'
nix-update:
uses: christianharke/flake-commons/.github/workflows/nix-update.yml@main
with:
branch: ${{ needs.update.outputs.branch }}

merge:
runs-on: ubuntu-latest
needs:
- update
- build

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check if update branch is behind master
run: git diff origin/${{ needs.update.outputs.branch }}...origin/master --exit-code

- name: Merge update into master
run: git merge origin/${{ needs.update.outputs.branch }}

- name: Push master
run: git push origin master

- name: Delete update branch
run: git push --delete origin ${{ needs.update.outputs.branch }}
base-branch: master

0 comments on commit 304c0d7

Please sign in to comment.