-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
55 lines (51 loc) · 1.81 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
52
53
54
55
---
name: "Publish to preview server"
description: "Update kubernetes deployment image"
inputs:
kairos_url:
description: "Publish endpoint"
required: true
kairos_token:
description: "Authentication token to be able to upload artifacts"
required: true
zipfile:
description: "Zip file that contains all the assets to be published"
required: true
runs:
using: "composite"
steps:
- name: Upload compiled output
shell: bash
run: |
full_hash=$GITHUB_SHA
file="${full_hash:0:7}.zip"
mv ${{ inputs.zipfile }} $file
response=$(curl -D headers.txt -X POST -H "X-Api-Token:${{ inputs.kairos_token }}" -F "file=@$file" ${{ inputs.kairos_url }})
echo "Checking Kairo response..."
echo "HEADERS\n$(cat headers.txt)"
echo "RESPONSE\n$response"
cat headers.txt | grep " 200" || exit 1
echo "preview_url=$response" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Build body comment
shell: bash
run: |
git config --global --add safe.directory /__w/playbook/playbook
# we need to fetch references to be able to get diff
git fetch origin
echo "preview_body<<EOF" >> $GITHUB_ENV
for file in $(git diff --name-only origin/$GITHUB_BASE_REF | grep ".md" | sed s/.md$//); do
inner=$(echo "$file" | sed s/^content// | sed s/.md$//)
echo "- $preview_url$inner" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
- name: Notify preview URL into PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Previews:\n ${process.env.preview_body}`
})