Geo cord polygon query #1216
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: CI | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
tags: | |
- v* | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
IMAGE_NAME_BASE: seerep_base | |
IMAGE_NAME_SERVER: seerep_server | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
create-ids: | |
runs-on: ubuntu-20.04 | |
outputs: | |
base_id: ${{ steps.tagsBase.outputs.base_id }} | |
server_id: ${{ steps.tagsServer.outputs.server_id }} | |
version: ${{ steps.tagsBase.outputs.version }} | |
steps: | |
- | |
id: tagsBase | |
name: Generate tags base | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_BASE | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[[ "${{ github.ref }}" != "refs/tags/"* ]] && VERSION=latest | |
echo "base_id=$IMAGE_ID" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- | |
id: tagsServer | |
name: Generate tags server | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_SERVER | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# save to output | |
echo "server_id=$IMAGE_ID" >> $GITHUB_OUTPUT | |
# builds the docker image if the corresponding files changed | |
build-docker: | |
needs: create-ids | |
# run on ubuntu | |
runs-on: ubuntu-20.04 | |
permissions: | |
packages: write | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
# check if files have changed | |
- name: Get changed files | |
id: changed-files-specific-docker-base | |
uses: tj-actions/changed-files@v42 | |
with: | |
files: | | |
docker/base/Dockerfile | |
docker/base/requirements.dev.txt | |
docker/base/requirements.docs.txt | |
- | |
name: Set up Docker Buildx | |
if: github.ref_type == 'tag' || steps.changed-files-specific-docker-base.outputs.any_changed == 'true' | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to Container Registry | |
if: github.ref_type == 'tag' || steps.changed-files-specific-docker-base.outputs.any_changed == 'true' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build and push base image | |
if: github.ref_type == 'tag' || steps.changed-files-specific-docker-base.outputs.any_changed == 'true' | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile | |
context: "{{defaultContext}}:docker/base" | |
push: ${{ GitHub.event_name != 'pull_request'}} | |
tags: ${{ needs.create-ids.outputs.base_id }}:${{ needs.create-ids.outputs.version }} | |
cache-from: type=registry,ref=${{ needs.create-ids.outputs.base_id }}:${{ needs.create-ids.outputs.version }} | |
cache-to: type=inline | |
build-code: | |
needs: [build-docker, create-ids] | |
runs-on: ubuntu-20.04 | |
container: | |
image: ${{ needs.create-ids.outputs.base_id }}:${{ needs.create-ids.outputs.version }} | |
options: --user root | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: src | |
fetch-depth: 0 | |
- name: Build ROS workspace | |
run: | | |
source /opt/ros/noetic/setup.bash | |
catkin build --workspace $GITHUB_WORKSPACE/ | |
shell: bash | |
- name: Run pre-commit tests | |
run: | | |
source /opt/ros/noetic/setup.bash | |
source $GITHUB_WORKSPACE/devel/setup.bash | |
cd $GITHUB_WORKSPACE/src; pre-commit run -a | |
shell: bash | |
- name: Build pypi packages | |
run: | | |
cd $GITHUB_WORKSPACE/src | |
python3 -m build --wheel | |
- name: Publish packages to pypi | |
if: github.ref_type == 'tag' | |
env: | |
TWINE_USERNAME: "__token__" | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
twine upload $GITHUB_WORKSPACE/src/dist/* | |
build-docker-deployment: | |
needs: [build-code, create-ids] | |
# run on ubuntu | |
runs-on: ubuntu-20.04 | |
permissions: | |
packages: write | |
if: ${{ GitHub.event_name != 'pull_request'}} | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build and push server image | |
uses: docker/build-push-action@v5 | |
with: | |
file: docker/server/Dockerfile | |
push: ${{ GitHub.event_name != 'pull_request'}} | |
tags: ${{ needs.create-ids.outputs.server_id }}:${{ needs.create-ids.outputs.version }} | |
cache-from: type=registry,ref=${{ needs.create-ids.outputs.server_id }}:${{ needs.create-ids.outputs.version }} | |
cache-to: type=inline | |
build-args: | | |
IMAGEBASE=${{ needs.create-ids.outputs.base_id }} | |
IMAGEBASETAG=${{ needs.create-ids.outputs.version }} |