Merge pull request #122 from YoheiKakiuchi/pr_cp_color #179
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
name: BuildTestDeploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
ubuntu: [22.04, 20.04] | |
runs-on: self-hosted | |
env: | |
IMAGE_NAME: choreonoid_robot_assembler_plugin | |
LOCAL_NAME: actions/robot_assembler_plugin | |
# DOCKER_LOCAL: ghcr.io/ | |
DOCKER_LOCAL: repo.irsl.eiiris.tut.ac.jp/ | |
DOCKER_DEPLOY: repo.irsl.eiiris.tut.ac.jp/ | |
DOCKER_TAG: ${{ matrix.ubuntu }} | |
steps: | |
- run: echo "π© The job was automatically triggered by a ${{ github.event_name }} event." | |
- run: echo "π The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Build a Docker image | |
run: > | |
docker build -f .github/workflows/Dockerfile.testbuild | |
--build-arg BUILD_IMAGE=${{ env.DOCKER_LOCAL }}xeus:${{ env.DOCKER_TAG }} | |
--build-arg BASE_IMAGE=${{ env.DOCKER_LOCAL }}choreonoid_src:${{ env.DOCKER_TAG }} | |
-t ${{ env.LOCAL_NAME }}:${{ github.sha }} .. | |
- run: echo "π Successfully built a Docker image." | |
- run: echo "πͺ Running Google Test in the Docker image." | |
- name: Google Test | |
run: docker run --rm ${{ env.LOCAL_NAME }}:${{ github.sha }} /bin/bash -c "/choreonoid_src/build/bin/test-sample" | |
- run: echo "β Congratulations! All tests passed." | |
- name: Deploy the Docker image | |
if: github.event_name == 'push' | |
run: | | |
docker tag ${{ env.LOCAL_NAME }}:${{ github.sha }} ${{ env.DOCKER_DEPLOY }}${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} | |
docker push ${{ env.DOCKER_DEPLOY }}${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} | |
- run: echo "π³ Successfully pushed the Docker image to ${{ env.DOCKER_DEPLOY }}." | |
- name: Dispatch | |
if: github.event_name == 'push' && matrix.ubuntu == '20.04' | |
env: | |
GITHUB_TOKEN: ${{ secrets.IRSL_PAT_CLS }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.IRSL_PAT_CLS }} | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: 'IRSL-tut', | |
repo: 'irsl_docker_irsl_system', | |
ref: 'main', | |
workflow_id: 'build-irsl-system.yaml', | |
inputs: { | |
event_type: 'build_all', | |
source: 'robot_assembler_plugin', | |
hash: '${{ github.sha }}' | |
} | |
}) | |
- run: echo "π This job's status is ${{ job.status }}." |