Skip to content

Merge pull request #280 from robotology/feat/add-gz-sim-support #1907

Merge pull request #280 from robotology/feat/add-gz-sim-support

Merge pull request #280 from robotology/feat/add-gz-sim-support #1907

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
push:
description: 'If true, actually push to the specified branch specified in the branch option.'
required: true
default: 'false'
branch:
description: 'Branch of icub-models to which the action will push'
required: true
default: 'devel'
schedule:
# * is a special character in YAML so you have to quote this string
# Execute a "nightly" build at 2 AM UTC
- cron: '0 2 * * *'
env:
DEPLOYMENT_REPOSITORY: "robotology/icub-models"
TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT: "refs/heads/master"
TRIGGERING_REPOSITORY_URL_VALID_FOR_DEPLOYMENT: "https://github.com/robotology/icub-model-generator.git"
BOT_USER_NAME: "LOC2Bot"
ICUB_MODELS_BRANCH: "devel"
ICUB_MODELS_SOURCE_DIR: "/home/runner/work/icub-model-generator/icub-model-generator/icub-models"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Change ICUB_MODELS_BRANCH if necessary
shell: bash
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "ICUB_MODELS_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
# Print environment variables to simplify development and debugging
- name: Environment Variables
shell: bash
run: env
- uses: prefix-dev/setup-pixi@v0.5.1
- name: Generate models
run: |
# Clone icub-models repo
git clone -b $ICUB_MODELS_BRANCH https://github.com/${DEPLOYMENT_REPOSITORY}.git ${ICUB_MODELS_SOURCE_DIR}
# Delete files in iCub directory of icub-models, as they are the one meant to be generated automatically every time
# See https://github.com/robotology/icub-models/issues/185
cd ${ICUB_MODELS_SOURCE_DIR}
git rm -rf ./iCub
# Test and copy new files to icub-models repo
cd ${GITHUB_WORKSPACE}
pixi run test_generated_models
pixi run copy_models_to_icub_models
- name: Print generated models differences and add files
run: |
cd $ICUB_MODELS_SOURCE_DIR
git diff
# Add any new generated file
git add --all
git status
- name: Commit models
if: ${{ (github.event_name == 'push' && github.ref == env.TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT) || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }}
run: |
# See https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
export GIT_COMMITTER_NAME="$(git --no-pager show -s --format='%cn' $GITHUB_SHA)"
export GIT_AUTHOR_NAME="$(git --no-pager show -s --format='%an' $GITHUB_SHA)"
export GIT_COMMITTER_EMAIL="$(git --no-pager show -s --format='%ce' $GITHUB_SHA)"
export GIT_AUTHOR_EMAIL="$(git --no-pager show -s --format='%ae' $GITHUB_SHA)"
echo "Commit committer is $GIT_COMMITTER_NAME (email: $GIT_COMMITTER_EMAIL)"
echo "Commit author is $GIT_AUTHOR_NAME (email: $GIT_AUTHOR_EMAIL)"
cd $ICUB_MODELS_SOURCE_DIR
# See https://stackoverflow.com/a/32507305
git commit -a -F ${GITHUB_WORKSPACE}/deploy_commit_message || echo "No changes in the icub-models branch, so no commit was done."
- name: Push models
uses: ad-m/github-push-action@v0.6.0
if: ${{ (github.event_name == 'push' && github.ref == env.TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT) || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }}
with:
directory: ${{ env.ICUB_MODELS_SOURCE_DIR }}
repository: ${{ env.DEPLOYMENT_REPOSITORY }}
branch: ${{ env.ICUB_MODELS_BRANCH }}
github_token: ${{ secrets.ICUB_MODELS_GENERATOR_TOKEN }}