-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (65 loc) · 2.28 KB
/
update-pkg.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Update a package
on:
workflow_dispatch:
inputs:
package:
type: string
required: true
version:
type: string
default: "latest"
deploy:
type: boolean
default: true
description: Trigger deployment after updating the package.
jobs:
update:
name: Update ${{ inputs.package }}
runs-on: ubuntu-22.04
outputs:
updated: ${{ steps.update-pkg.outputs.updated }}
commit_hash: ${{ steps.git-commit.outputs.commit_hash }}
steps:
- uses: actions/checkout@v3
with:
# Use ref_name instead of ref so we always get the branch to pull our
# latest commit from.
ref: ${{ github.ref_name }}
- name: Install Nix packages
id: nix-install
uses: diamondburned/cache-install@main
with:
shell-file: shell.nix
instantiated-files: packages/
- name: Update package ${{ inputs.package }} to ${{ inputs.version }}
id: update-pkg
run: |-
./scripts/pkg update "${{ inputs.package }}" "${{ inputs.version }}"
# Check if there has been any git changes. updated=1 if there's one,
# otherwise it's 0. We'll skip the rest if 0.
if [[ $(git status --porcelain) ]]; then
echo "updated=1" >> $GITHUB_OUTPUT
fi
env:
# Set the GITHUB_TOKEN variable to prevent 403 errors.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package ${{ inputs.package }}
if: steps.update-pkg.outputs.updated == 1
run: nix-build ./packages -A "${{ inputs.package }}"
- name: Commit changes, if any
id: git-commit
if: steps.update-pkg.outputs.updated == 1
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: |-
Update package ${{ inputs.package }} using GitHub Actions
Package ${{ inputs.package }} was updated to version:
${{ inputs.version }}
The action workflow was triggered by ref:
${{ github.sha }}
branch: ${{ github.ref_name }}
deploy:
needs: update
if: needs.update.outputs.updated == 1 && inputs.deploy == true
uses: ./.github/workflows/deploy.yml
secrets: inherit