-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yaml
65 lines (60 loc) · 2.24 KB
/
action.yaml
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
name: 'Publish flakestry.dev'
description: 'Release flake to flakestry.dev'
inputs:
version:
description: 'Version of the flake to be released'
required: false
ref:
description: 'Git reference to be released'
required: false
url:
description: 'Flakestry URL'
required: true
default: 'https://flakestry.dev'
ignoreConflicts:
description: "Don't fail if the version already exists"
required: false
# allowEvalErrors:
# description: 'Allow eval errors'
# required: false
# default: 'true'
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.version }}
- uses: cachix/install-nix-action@v22
- shell: bash
run: |
echo null > metadata.err
echo null > metadata.json
echo null > outputs.json
nix flake metadata --json > metadata.json 2> metadata.err || echo "nix flake metadata --json failed"
nix flake show --json --all-systems > outputs.json 2> outputs.err || echo "nix flake show --json --all-systems failed"
if [ ! -e metadata.json ]; then
echo null > metadata.json
fi
if [ ! -e outputs.json ]; then
echo null > outputs.json
fi
RESPONSE=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=${{ inputs.url }}")
OIDC=$(echo $RESPONSE | jq -r '.value')
README=$(find . -iname "README*" -maxdepth 1 -print -quit)
nix run nixpkgs#jo \
metadata=:metadata.json \
outputs=:outputs.json \
readme="$README" \
version="${{ inputs.version || null }}" \
ref="${{ inputs.ref || github.sha }}" \
> publish.json
echo "Publishing to ${{ inputs.url }}"
curl --fail-with-body -w '%{http_code}' -o /dev/stderr > http_code \
-H 'Content-Type: application/json' \
-H "Github-Token: ${{ github.token }}" \
-H "Authorization: Bearer $OIDC" \
-d @publish.json \
-X POST ${{ inputs.url }}/api/publish \
|| ([ "${{ inputs.ignoreConflicts || false }}" = 'true' ] && grep -qxF 409 http_code)