ci: simplify workflows

Link: https://github.com/danth/stylix/pull/519
This commit is contained in:
NAHO 2024-08-21 18:14:01 +02:00
parent fe72c2306f
commit 2b85a56235
No known key found for this signature in database
GPG key ID: 229CB671D09B95F5
3 changed files with 36 additions and 85 deletions

View file

@ -10,7 +10,6 @@ permissions: {}
jobs:
backport:
name: Backport
runs-on: ubuntu-latest
if: >
@ -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}."

View file

@ -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
- uses: DeterminateSystems/nix-installer-action@v16
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: List packages
id: list-packages
- 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

View file

@ -1,3 +1,4 @@
---
name: Docs
on:
@ -5,53 +6,31 @@ on:
branches:
- master
concurrency:
cancel-in-progress: true
group: pages
jobs:
build:
name: Build
docs:
runs-on: ubuntu-24.04
permissions:
contents: read
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
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