Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA builds only when Garnix fails evaluation check #286

Merged
merged 22 commits into from
Jan 23, 2025
25 changes: 25 additions & 0 deletions .github/actions/garnix-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Garnix status check
description: Determines whether to build the Nix config on GHA or not based on the Garnix status check
inputs:
github_token:
required: true
outputs:
status:
description: "The status check response, which may be failure or success"
value: ${{ steps.garnix.outputs.status }}
runs:
using: "composite"
steps:
# I got the check suite ID from: https://api.github.com/repos/gvolpe/nix-config/commits/REF/check-runs
# where REF == branch name (didn't work with the commit sha for some reason)
- name: Garnix check status
id: garnix
shell: bash
run: |
STATUS=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ inputs.github_token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/gvolpe/nix-config/check-suites/33419075802/check-runs | \
jq -r '.check_runs | .[] | select (.output.text | contains("monthly CI quota")) | select (.status == "completed") | .conclusion')
echo "status=$STATUS" | tee -a "$GITHUB_OUTPUT"
19 changes: 19 additions & 0 deletions .github/workflows/home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,28 @@ on:
- 'garnix.yaml'

jobs:
checks:
runs-on: ubuntu-latest

outputs:
garnix: ${{ steps.garnix.outputs.status }}

steps:
- uses: actions/[email protected]

- name: Garnix check status
id: garnix
uses: ./.github/actions/garnix-check
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

build:
runs-on: ubuntu-latest

needs: checks

if: needs.checks.outputs.garnix == 'failure'

strategy:
fail-fast: true
matrix:
Expand Down
54 changes: 24 additions & 30 deletions .github/workflows/nixos.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: NixOS

on:
check_run:
types: [failure]
pull_request:
paths-ignore:
- 'home/**'
push:
branches:
- master
paths-ignore:
- 'GNOME.md'
- 'README.md'
Expand All @@ -15,34 +19,29 @@ on:
- 'switch'
- '.mergify.yml'
- 'garnix.yaml'
#on:
#pull_request:
#paths-ignore:
#- 'home/**'
#push:
#branches:
#- master
#paths-ignore:
#- 'GNOME.md'
#- 'README.md'
#- 'notes/**'
#- '.git-crypt/**'
#- '.gitattributes'
#- '.gitignore'
#- 'home/**'
#- 'outputs/hm.nix'
#- 'switch'
#- '.mergify.yml'
#- 'garnix.yaml'

jobs:
checks:
runs-on: ubuntu-latest

outputs:
garnix: ${{ steps.garnix.outputs.status }}

steps:
- uses: actions/[email protected]

- name: Garnix check status
id: garnix
uses: ./.github/actions/garnix-check
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

build:
runs-on: ubuntu-latest

#if: github.action == 'Garnix CI / Evaluate flake.nix'
#if: >-
#github.event.state == 'error' ||
#github.event.state == 'failure'
needs: checks

if: needs.checks.outputs.garnix == 'failure'

strategy:
fail-fast: true
Expand All @@ -56,11 +55,6 @@ jobs:
steps:
- uses: actions/[email protected]

- name: "DEBUG"
run: |
echo "Event state: ${{ github.event.state }}"
echo "Event desc: ${{ github.event.description }}"

- name: "Install Nix ❄️"
uses: cachix/install-nix-action@v30

Expand Down
Loading