-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (100 loc) · 3.64 KB
/
deploy.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Skpr Deploy
on:
workflow_call:
inputs:
env:
type: string
required: true
description: The Skpr environment to deploy to.
package:
default: true
type: boolean
description: Whether this deployment needs to be packaged.
version:
type: string
description: The version to deploy
version_from_env:
type: string
description: Get the version to deploy from the environment.
suspend_cron:
type: boolean
default: false
description: Pause Cron operations during the deployment.
post_deploy:
default: make deploy
type: string
description: The post deploy commands to run on the environment.
secrets:
skpr_username:
required: true
skpr_password:
required: true
outputs:
version:
description: The version deployed
value: ${{ jobs.deploy.outputs.version }}
url:
description: The URL of the environment
value: ${{ jobs.deploy.outputs.url }}
env:
SKPR_USERNAME: ${{ secrets.SKPR_USERNAME }}
SKPR_PASSWORD: ${{ secrets.SKPR_PASSWORD }}
GH_TOKEN: ${{ github.token }}
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.env }}
url: ${{ steps.skpr-info.outputs.url }}
concurrency: ${{ inputs.env }}
outputs:
version: ${{ steps.version.outputs.version }}
url: ${{ steps.skpr-info.outputs.url }}
steps:
- name: ⬇️ Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: ⚙️ Install Skpr CLI
run: |
wget -q https://packages.skpr.io/apt/packages.skpr.io.pub -O- | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/packages.skpr.io.pub > /dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.skpr.io.pub] https://packages.skpr.io/apt stable main" | sudo tee -a /etc/apt/sources.list.d/skpr.list > /dev/null
sudo apt update && sudo apt install skpr
- name: 🔢 Get version
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
version=${{ inputs.version }}
echo "::notice:: Using explicit version $version"
elif [ -n "${{ inputs.version_from_env }}" ]; then
version=$(skpr info ${{ inputs.version_from_env }} | jq -r ".Version")
echo "::notice:: Using version $version from ${{ inputs.version_from_env }} env"
elif [ "${{ github.ref_type}}" == "tag" ]; then
version=${{ github.ref_name }}
echo "::notice:: Using version $version from github.ref_name context"
else
version=$(git describe --tags --always)
echo "::notice:: Using version $version from git describe"
fi
echo "version=$version" >> $GITHUB_OUTPUT
- name: ℹ️ Info
id: skpr-info
shell: bash
run: |
domain=$(skpr info ${{ inputs.env }} | jq -r ".Ingress.Domain")
url=https://$domain
echo "url=$url" >> $GITHUB_OUTPUT
- name: 📦 Package
if: inputs.package
run: skpr package ${{ steps.version.outputs.version }}
- name: ⏸️ Suspend Cron
if: inputs.suspend_cron
run: skpr cron suspend ${{ inputs.env }} --wait
- name: 🚀 Deploy
run: skpr deploy ${{ inputs.env }} ${{ steps.version.outputs.version }}
- name: ▶️ Resume Cron
if: inputs.suspend_cron
run: skpr cron resume ${{ inputs.env }}
- name: 🧹 Post-deploy
run: skpr exec ${{ inputs.env }} ${{ inputs.post_deploy }}