-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Replace single DEPLOY_MODE with - CONTENT_MODE: replace | add | newer - PUSH_MODE: push | amend | squash - Fix concurrency groups - Fix CI workflow triggers
- Loading branch information
Showing
17 changed files
with
365 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: reusable deploy workflow | ||
|
||
on: | ||
# make this workflow reusable (and only so) | ||
workflow_call: | ||
inputs: | ||
DEPLOY_URL: | ||
type: string | ||
description: Where to deploy? | ||
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: | ||
group: ${{ github.workflow }}-deploy-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
if: inputs.DEPLOY_URL || vars.DEPLOY_URL | ||
env: | ||
DEBUG_BASH: ${{ secrets.ACTIONS_STEP_DEBUG && 'true' || 'false' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Download debs artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
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 }} | ||
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) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ on: | |
required: true | ||
description: 'ROS distribution codename:' | ||
default: one | ||
|
||
ROS_SOURCES: | ||
type: string | ||
description: 'ROS sources to compile:' | ||
|
@@ -26,65 +27,55 @@ on: | |
type: string | ||
description: 'colcon package selection:' | ||
required: false | ||
SKIP_EXISTING: | ||
|
||
CONTINUE_BUILD: | ||
type: boolean | ||
description: Skip existing packages? | ||
required: false | ||
description: Continue build? | ||
required: true | ||
default: false | ||
|
||
# Installing built packages to chroot speeds up downstream builds | ||
INSTALL_TO_CHROOT: | ||
type: boolean | ||
description: Incrementally fill chroot? | ||
required: false | ||
DEPLOY_MODE: | ||
|
||
PUSH_MODE: | ||
type: choice | ||
description: How to deploy? | ||
description: Push to DEPLOY_URL? | ||
required: true | ||
default: skip | ||
options: | ||
- skip | ||
- push | ||
- amend | ||
- squash | ||
- append | ||
BRANCH: | ||
type: string | ||
description: 'Branch to use:' | ||
required: false | ||
|
||
env: | ||
BRANCH: ${{ inputs.BRANCH || format('{0}-{1}', inputs.DEB_DISTRO, inputs.ROS_DISTRO) }} | ||
|
||
jobs: | ||
build: | ||
name: ${{ inputs.DEB_DISTRO || vars.DEB_DISTRO || 'latest' }}-${{ inputs.ROS_DISTRO || vars.ROS_DISTRO || 'one'}} | ||
uses: ubi-agni/ros-builder-action/.github/workflows/generic.yaml@main | ||
uses: ubi-agni/ros-builder-action/.github/workflows/build.yaml@main | ||
with: | ||
DEB_DISTRO: ${{ inputs.DEB_DISTRO || vars.DEB_DISTRO }} | ||
ROS_DISTRO: ${{ inputs.ROS_DISTRO || vars.ROS_DISTRO || 'one' }} | ||
ROS_SOURCES: ${{ inputs.ROS_SOURCES || vars.ROS_SOURCES }} | ||
COLCON_PKG_SELECTION: ${{ inputs.COLCON_PKG_SELECTION || vars.COLCON_PKG_SELECTION || '' }} | ||
# proceed from existing debs artifact if run_attempt > 1 | ||
DOWNLOAD_DEBS: ${{ github.run_attempt != '1' }} | ||
SKIP_EXISTING: ${{ inputs.SKIP_EXISTING || vars.SKIP_EXISTING || false}} | ||
SKIP_EXISTING: ${{ inputs.CONTINUE_BUILD }} | ||
INSTALL_TO_CHROOT: ${{ inputs.INSTALL_TO_CHROOT || vars.INSTALL_TO_CHROOT || false }} | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: ( inputs.DEPLOY_MODE != 'skip' ) && vars.DEPLOY_URL | ||
|
||
env: # define common environment variables (cannot be passed from calling workflow) | ||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 10 | ||
FOLDER: ${{ vars.DEBS_PATH || '~/debs' }} | ||
REPO: ${{ vars.DEPLOY_URL }} | ||
|
||
steps: | ||
- name: Download debs from build | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: debs | ||
path: ${{ env.FOLDER }} | ||
|
||
- name: Deploy | ||
uses: s0/[email protected] | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }} | ||
MESSAGE: "${{ inputs.DEB_DISTRO }}-${{ inputs.ROS_DISTRO }} build" | ||
SQUASH_HISTORY: ${{ inputs.DEPLOY_MODE == 'squash' }} | ||
if: always() && ( inputs.PUSH_MODE != 'skip' ) && vars.DEPLOY_URL | ||
uses: ubi-agni/ros-builder-action/.github/workflows/deploy.yaml@main | ||
with: | ||
# content mode: 'add' if continueing build, 'replace' otherwise | ||
CONTENT_MODE: ${{ inputs.CONTINUE_BUILD && 'add' || 'replace' }} | ||
# default push mode: 'push' if continueing build, 'squash' otherwise | ||
PUSH_MODE: ${{ inputs.PUSH_MODE || vars.PUSH_MODE || (inputs.CONTINUE_BUILD && 'push' || 'squash') }} | ||
MESSAGE: "${{ needs.build.outputs.LATEST_PACKAGE \ | ||
&& format('build up to {0}', needs.build.outputs.LATEST_PACKAGE) \ | ||
|| format('{0}-{1}', inputs.DEB_DISTRO || vars.DEB_DISTRO, inputs.ROS_DISTRO || vars.ROS_DISTRO || 'one') }}" | ||
secrets: | ||
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }} |
Oops, something went wrong.