-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
51 lines (49 loc) · 1.69 KB
/
action.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
name: 'CD ping'
description: 'Notify a repository that a new release is available'
inputs:
from:
description: 'The ping sender'
required: true
is_composite:
description: 'Is the pig sender a composite action repository ?'
required: false
default: 'false'
event:
description: 'Event to trigger'
required: false
default: 'ping'
to:
description: 'The ping receiver'
required: true
tag:
description: 'The pushed tag'
required: true
token:
description: 'The github token'
required: true
runs:
using: "composite"
steps:
- uses: tiawl/[email protected]
- if: inputs.is_composite != 'true'
uses: mlugg/setup-zig@v1
with:
version: ${{ env.zig_version }}
- name: Notify ${{ inputs.to }}
env:
ENDPOINT: "/repos/${{ github.repository_owner }}/${{ inputs.to }}/dispatches"
EVENT_TYPE: "event_type=${{ inputs.event }}-from-${{ inputs.from }}"
GH_TOKEN: "${{ inputs.token }}"
IS_COMPOSITE: "${{ inputs.is_composite }}"
PAYLOAD_FROM: "client_payload[from]=${{ inputs.from }}"
PAYLOAD_TAG: "client_payload[tag]=${{ inputs.tag }}"
URL: "${{ github.server_url }}/${{ github.repository_owner }}/${{ inputs.from }}/archive/refs/tags/${{ inputs.tag }}.tar.gz"
shell: ${{ env.shell }}
run: |
payload_hash="client_payload[hash]=$(if [[ "${IS_COMPOSITE}" != 'true' ]]; then zig fetch "${URL}"; fi)"
gh api --method POST \
-H 'Accept: application/vnd.github+json' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
-f "${EVENT_TYPE}" \
-F "${PAYLOAD_FROM}" -F "${PAYLOAD_TAG}" -F "${payload_hash}" \
"${ENDPOINT}"