-
Notifications
You must be signed in to change notification settings - Fork 6
108 lines (96 loc) · 3.89 KB
/
deploy.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
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
104
105
106
107
108
name: reusable deploy workflow
on:
# make this workflow reusable (and only so)
workflow_call:
inputs:
DEBS_ARTIFACT_NAME:
type: string
description: name of debs artifact to deploy from
required: false
DEPLOY_URL:
type: string
description: Where to deploy?
required: false
DEPLOY_FILES:
type: string
description: Which file types to deploy?
required: false
DEPLOY_FILE_SIZE_LIMIT:
type: string
description: Size limit for files to deploy (specify units as K, M, or G)
required: false
CONTENT_MODE:
type: string
description: |
How to handle existing packages?
- replace
- add (keep existing packages)
- newer (keep existing, but remove older versions)
required: false
PUSH_MODE:
type: string
description: push | amend | squash
required: false
DEBS_PATH:
type: string
description: path to store generated .debs in
required: false
COMMIT_NAME:
type: string
description: user name for commit
required: false
COMMIT_EMAIL:
type: string
description: user email for commit
required: false
MESSAGE:
type: string
description: Commit message
required: false
secrets:
SSH_PRIVATE_KEY:
description: SSH private key to use for deployment
required: false
TOKEN:
description: github token for pushing to own repo
required: false
# Define environment variables from input, from configuration variables, or defaults - in this order!
# All inputs (declared above) are deliberately optional and don't provide an explicit default.
# Thus, if an input is not explicitly provided, we can fall back to the configuration variable here (var.* context).
# This variable context originates from the _calling_ workflow. Finally, a hard-coded default is given.
# https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows
env:
DEBS_PATH: ${{ inputs.DEBS_PATH || vars.DEBS_PATH || '~/debs' }}
concurrency:
# Ensure exclusive access to deployment target
group: ${{ inputs.DEPLOY_URL || vars.DEPLOY_URL }}
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-22.04
if: (inputs.DEPLOY_URL || vars.DEPLOY_URL) && (inputs.DEBS_ARTIFACT_NAME != 'skip')
env:
DEBUG_BASH: ${{ secrets.ACTIONS_STEP_DEBUG && 'true' || 'false' }}
steps:
- uses: actions/checkout@v4
- name: Download debs artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.DEBS_ARTIFACT_NAME || 'debs' }}
path: ${{ env.DEBS_PATH }}
- name: Deploy to ${{ inputs.DEPLOY_URL || vars.DEPLOY_URL }}
run: |
echo "Cloning and running deploy script"
git clone --branch main --depth 1 https://github.com/ubi-agni/ros-builder-action.git $RUNNER_TEMP/ros-builder-action
$RUNNER_TEMP/ros-builder-action/src/scripts/generic.sh $RUNNER_TEMP/ros-builder-action/src/scripts/deploy.sh
env:
DEPLOY_URL: ${{ inputs.DEPLOY_URL || vars.DEPLOY_URL }}
DEPLOY_FILES: ${{ inputs.DEPLOY_FILES || vars.DEPLOY_FILES || 'deb' }}
DEPLOY_FILE_SIZE_LIMIT: ${{ inputs.DEPLOY_FILE_SIZE_LIMIT || vars.DEPLOY_FILE_SIZE_LIMIT || '' }}
TOKEN: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
CONTENT_MODE: ${{ inputs.CONTENT_MODE || vars.CONTENT_MODE || 'newer' }}
PUSH_MODE: ${{ inputs.PUSH_MODE || vars.PUSH_MODE || 'push' }}
MESSAGE: ${{ inputs.MESSAGE || 'deploy' }}
COMMIT_NAME: ${{ inputs.COMMIT_NAME || github.actor }}
COMMIT_EMAIL: ${{ inputs.COMMIT_EMAIL || format('{0}@users.noreply.github.com', github.actor) }}