generated from DeskproApps/app-template-vite
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (78 loc) · 3.1 KB
/
subworkflow-release.yml
File metadata and controls
86 lines (78 loc) · 3.1 KB
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
78
79
80
81
82
83
84
85
86
name: "Release to App Marketplace"
on:
workflow_call:
inputs:
server_url:
type: string
description: "The URL of the GitHub server URL."
default: ${{ github.server_url }}
required: false
repository:
type: string
description: "The owner and repository name to release."
default: ${{ github.repository }}
required: false
secrets:
APP_REGISTRY_KEY: { required: true }
jobs:
release:
name: Release App
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download package
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: app-package
path: app-package
- name: Create safe package
id: package
working-directory: app-package
run: |
packageFilename=`jq -r .name manifest.json | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z`
mv app.zip $packageFilename.zip
echo "version=`jq -r .version manifest.json`" >> $GITHUB_OUTPUT
echo "packageFilename=$packageFilename.zip" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
files: |
./app-package/${{ steps.package.outputs.packageFilename }}
./app-package/manifest.json
- name: Check if can release to Deskpro Infrastructure
id: check_deskpro_release
run: |
if [ "${{ github.repository_visibility }}" != "public" ]; then
echo "Repository is not public. Skipping deployment."
echo "can_deploy=false" >> $GITHUB_OUTPUT
elif [ -z "${{ secrets.APP_REGISTRY_KEY }}" ]; then
echo "APP_REGISTRY_KEY is not set. Skipping deployment."
echo "can_deploy=false" >> $GITHUB_OUTPUT
else
echo "can_deploy=true" >> $GITHUB_OUTPUT
fi
- name: Register release with apps registry
if: steps.check_deskpro_release.outputs.can_deploy == 'true'
run: |
curl --fail -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: ${{ secrets.APP_REGISTRY_KEY }}" \
-d '{"repositoryUrl": "'${{ inputs.server_url }}/${{ inputs.repository }}'", "type": "github"}' \
https://apps.deskpro-service.com/register
- name: Trigger release
if: steps.check_deskpro_release.outputs.can_deploy == 'true'
run: |
curl --fail -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: ${{ secrets.APP_REGISTRY_KEY }}" \
-d '{"repositoryUrl": "'${{ inputs.server_url }}/${{ inputs.repository }}'"}' \
https://apps.deskpro-service.com/release