Skip to content

Commit 1806f6c

Browse files
committed
add: github workflows
1 parent 2a3e05d commit 1806f6c

File tree

5 files changed

+174
-0
lines changed

5 files changed

+174
-0
lines changed

.github/workflows/auto-review.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Auto review
2+
on:
3+
workflow_run:
4+
workflows: [Build check]
5+
types:
6+
- completed
7+
8+
jobs:
9+
run-test:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
steps:
13+
- uses: actions/checkout@v3.3.0
14+
15+
- name: Download artifact
16+
id: download-artifact
17+
uses: dawidd6/action-download-artifact@v2
18+
with:
19+
workflow: build-check.yml
20+
workflow_conclusion: success
21+
name: pr-number
22+
path: artifacts
23+
24+
- name: Set PR number
25+
id: pr-number
26+
run: echo pr-number=$(cat ./artifacts/pr-number.txt) >> $GITHUB_OUTPUT
27+
28+
- name: PR review and merge
29+
env:
30+
GITHUB_TOKEN: ${{ github.token }}
31+
run: |
32+
gh pr review --approve ${{ steps.pr-number.outputs.pr-number }}
33+
gh pr merge --merge --auto ${{ steps.pr-number.outputs.pr-number }}
34+
35+
on-failure:
36+
runs-on: ubuntu-latest
37+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
38+
steps:
39+
- uses: actions/checkout@v3.3.0
40+
41+
- name: Download artifact
42+
id: download-artifact
43+
uses: dawidd6/action-download-artifact@v2
44+
with:
45+
workflow: build-check.yml
46+
workflow_conclusion: success
47+
name: pr-number
48+
path: artifacts
49+
50+
- name: Set PR number
51+
id: pr-number
52+
run: echo pr-number=$(cat ./artifacts/pr-number.txt) >> $GITHUB_OUTPUT
53+
54+
- name: Close PR
55+
env:
56+
GITHUB_TOKEN: ${{ github.token }}
57+
run: gh pr close ${{ steps.pr-number.outputs.pr-number }}

.github/workflows/build-check.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build check
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
build-check:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: easimon/maximize-build-space@master
10+
with:
11+
root-reserve-mb: 8192
12+
swap-size-mb: 1024
13+
build-mount-path: "/nix/store"
14+
remove-dotnet: true
15+
remove-android: true
16+
remove-haskell: true
17+
remove-codeql: true
18+
remove-docker-images: true
19+
20+
- uses: actions/checkout@v3.3.0
21+
22+
- name: Cache nvfetcher
23+
uses: actions/cache@v3.2.6
24+
with:
25+
path: ~/.local/share/nvfetcher
26+
key: ${{ runner.os }}-nvfetcher
27+
28+
- uses: cachix/install-nix-action@v20
29+
with:
30+
nix_path: nixpkgs=channel:nixos-unstable
31+
32+
- uses: cachix/cachix-action@v12
33+
with:
34+
name: misumisumi
35+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
36+
skipPush: true
37+
38+
- name: Run flake build
39+
run: nix flake check
40+
41+
- name: Save PR number
42+
run: echo $GITHUB_REF | sed -e 's/[^0-9]//g' > pr-number.txt
43+
44+
- name: Upload Artifact
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: pr-number
48+
path: pr-number.txt
49+
retention-days: 7
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Delete workflow
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
workflow:
7+
description: workflow-id, workflow-name or filename
8+
required: true
9+
type: string
10+
11+
jobs:
12+
delete:
13+
runs-on: ubuntu-20.04
14+
timeout-minutes: 1
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
GH_REPO: ${{ github.repository }}
18+
WORKFLOW: ${{ github.event.inputs.workflow }}
19+
20+
steps:
21+
- run: gh workflow view "${WORKFLOW}"
22+
- run: |
23+
gh run list --workflow "${WORKFLOW}" --limit 1000 --json databaseId,status --jq '.[] | select(.status == "completed") | .databaseId' \
24+
| xargs -n 1 -I {} gh api -X DELETE repos/${REPOSITORY}/actions/runs/{}
25+
env:
26+
REPOSITORY: ${{ github.repository }}

.github/workflows/format-check.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Format check
2+
on:
3+
push:
4+
branch-ignore:
5+
- "update_flake_lock_action"
6+
tags:
7+
- "*"
8+
paths:
9+
- "**.nix"
10+
pull_request:
11+
12+
jobs:
13+
nixpkgs-fmt:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: cachix/install-nix-action@v22
18+
with:
19+
nix_path: nixpkgs=channel:nixos-unstable
20+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
21+
- run: nix run nixpkgs#nixpkgs-fmt -- --check $(find ./ -type f -name "*.nix" | grep -v generated.nix)

.github/workflows/style-check.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Style check
2+
on:
3+
push:
4+
branch-ignore:
5+
- "update_flake_lock_action"
6+
tags:
7+
- "*"
8+
paths:
9+
- "**.nix"
10+
pull_request:
11+
12+
jobs:
13+
statix:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: cachix/install-nix-action@v22
18+
with:
19+
nix_path: nixpkgs=channel:nixos-unstable
20+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
21+
- run: nix run nixpkgs#statix check

0 commit comments

Comments
 (0)