Skip to content

Commit

Permalink
ci: simplify workflows
Browse files Browse the repository at this point in the history
Link: danth#519
(cherry picked from commit 2b85a56)
  • Loading branch information
trueNAHO committed Jan 4, 2025
1 parent a89ef5c commit 2352bb6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 86 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ permissions: {}

jobs:
backport:
name: Backport
runs-on: ubuntu-latest

if: >
Expand All @@ -23,23 +22,19 @@ jobs:
steps:
# Use a GitHub App rather than the default token so that GitHub Actions
# workflows may run on the created pull request.
- name: Create GitHub access token
uses: actions/create-github-app-token@v1
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.BACKPORT_APP_ID }}
private-key: ${{ secrets.BACKPORT_PRIVATE_KEY }}

- name: Checkout original pull request
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ steps.app-token.outputs.token }}

- name: Create backport pull request
uses: korthout/backport-action@v3
- uses: korthout/backport-action@v3
with:
github_token: ${{ steps.app-token.outputs.token }}
pull_title: "[${target_branch}] ${pull_title}"
pull_description: |-
This is an automated backport of #${pull_number}.
pull_description: "This is an automated backport of #${pull_number}."
53 changes: 15 additions & 38 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,37 @@ name: Check

on:
push:
branches:
- master
- release-**
pull_request:

permissions:
contents: read

jobs:
evaluate:
name: List packages
get-derivations:
runs-on: ubuntu-24.04

steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
extra-experimental-features = nix-command flakes
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@v8

- name: List packages
id: list-packages
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8

- id: get-derivations
run: |
nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "packages=\(.)"' >> $GITHUB_OUTPUT
nix flake show github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }} --json | jq -rc 'to_entries | map(.key as $type | select($type == "checks" or $type == "packages") | .value | to_entries | map(.key as $arch | select($arch == "x86_64-linux" or $arch == "x86_64-darwin") | .value | to_entries | map({type: $type, arch: $arch, os: (if $arch == "x86_64-linux" then "ubuntu-24.04" else "macos-14" end), key: .key})) | flatten) | flatten | "derivations=\(.)"' >> $GITHUB_OUTPUT
outputs:
packages: ${{ steps.list-packages.outputs.packages }}
derivations: ${{ steps.get-derivations.outputs.derivations }}

check:
needs: evaluate
runs-on: ${{ matrix.check.os }}

name: ${{ matrix.check.key }} on ${{ matrix.check.arch }}
needs: get-derivations

strategy:
fail-fast: false
matrix:
check: ${{ fromJSON(needs.evaluate.outputs.packages) }}

name: ${{ matrix.check.key }} on ${{ matrix.check.arch }}

runs-on: ${{ matrix.check.os }}
check: ${{ fromJSON(needs.get-derivations.outputs.derivations) }}

steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
extra-experimental-features = nix-command flakes
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@v8

- name: Check ${{ matrix.check.key }}
run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix -L check github:${{ github.repository }}/${{ github.event.pull_request.head.sha || github.sha }}#${{ matrix.check.type }}.${{ matrix.check.arch }}.${{ matrix.check.key }} --no-update-lock-file
57 changes: 18 additions & 39 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,36 @@
---
name: Docs

on:
push:
branches:
- master

jobs:
build:
name: Build

permissions:
contents: read
concurrency:
cancel-in-progress: true
group: pages

jobs:
docs:
runs-on: ubuntu-24.04

steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
extra-experimental-features = nix-command flakes
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@v8

- name: Build docs
run: nix -L build github:${{ github.repository }}/${{ github.sha }}#docs

- name: Prepare docs for upload
run: cp -r --dereference --no-preserve=mode,ownership result/ public/

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: public/

deploy:
name: Deploy

needs: build

permissions:
pages: write
contents: read
id-token: write
pages: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-24.04

steps:
- name: Deploy docs to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix build .#docs

- uses: actions/upload-pages-artifact@v3
with:
path: result

- uses: actions/deploy-pages@v4

0 comments on commit 2352bb6

Please sign in to comment.