Skip to content
Snippets Groups Projects
trigger_dockerhub.yaml 1.44 KiB
Newer Older
---
name: Trigger Docker Hub

on:
  schedule:
  # 7am UTC, 12am PDT
  - cron:  '0 7 * * *'
  push:
    branches:
    - main
    paths:
    - '**/package.xml'
    - '**/*.repos'

jobs:
  rebuild_dockerhub:
    name: Trigger Docker Hub
Ruffin's avatar
Ruffin committed
    runs-on: ubuntu-latest
    container:
      image: rosplanning/navigation2:main.release
    steps:
      - name: "Initialize environment"
        run: |
          echo "TRIGGER=false" >> $GITHUB_ENV
      - name: "Check apt updates"
        if: ${{ github.event_name == 'schedule' }}
        env:
          SOURCELIST: sources.list.d/ros2.list
        run: |
          apt-get update \
            -o Dir::Etc::sourcelist="${SOURCELIST}"
          apt-get --simulate upgrade \
            -o Dir::Etc::sourcelist="${SOURCELIST}" \
            | grep "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." \
            && echo "No apt updates" || echo "TRIGGER=true" >> $GITHUB_ENV
      - name: "Check package updates"
        if: ${{ github.event_name == 'push' }}
        run: |
          echo "TRIGGER=true" >> $GITHUB_ENV
      - name: "Trigger Dockerhub URL"
        if: ${{ fromJSON(env.TRIGGER) }}
Ruffin's avatar
Ruffin committed
            {
              "source_type": "Branch",
              "source_name": "main"
Ruffin's avatar
Ruffin committed
            }
Ruffin's avatar
Ruffin committed
          echo ${DATA} \
            | curl -H "Content-Type: application/json" \
              --data @- \
              -X POST ${{ secrets.DOCKERHUB_TRIGGER_URL }}