diff --git a/.github/workflows/dev_container.yml b/.github/workflows/dev_container.yml index 17bf12161cc7..5a80f224df9a 100644 --- a/.github/workflows/dev_container.yml +++ b/.github/workflows/dev_container.yml @@ -1,4 +1,3 @@ - name: Container build on: @@ -10,19 +9,26 @@ on: - 'release/**' tags: - 'v*' - paths: - - 'Tools/setup/ubuntu.sh' - - 'Tools/setup/requirements.txt' - - 'Tools/setup/Dockerfile' - - 'Tools/setup/docker-entrypoint.sh' pull_request: branches: - '*' paths: + - '.github/workflows/dev_container.yml' - 'Tools/setup/ubuntu.sh' - 'Tools/setup/requirements.txt' - 'Tools/setup/Dockerfile' - 'Tools/setup/docker-entrypoint.sh' + workflow_dispatch: + inputs: + px4_version: + description: 'Container tag (e.g. v1.16.0)' + required: true + type: string + deploy_to_registry: + description: 'Whether to push built images to the registry' + required: false + type: boolean + default: false jobs: setup: @@ -42,10 +48,15 @@ jobs: submodules: false fetch-depth: 0 + # If manual dispatch, take the user‐provided input - name: Set PX4 Tag Version id: px4_version run: | - echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "px4_version=${{ github.event.inputs.px4_version }}" >> $GITHUB_OUTPUT + else + echo "px4_version=$(git describe --tags --match 'v[0-9]*')" >> $GITHUB_OUTPUT + fi - name: Extract metadata (tags, labels) for Docker id: meta @@ -83,14 +94,14 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_registry) }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_registry) }} with: registry: ghcr.io username: ${{ github.actor }} @@ -113,7 +124,7 @@ jobs: labels: ${{ needs.setup.outputs.meta_labels }} platforms: ${{ matrix.platform }} load: false - push: ${{ startsWith(github.ref, 'refs/tags/') }} + push: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_registry) }} provenance: false cache-from: type=gha,version=1 cache-to: type=gha,version=1,mode=max @@ -125,7 +136,7 @@ jobs: packages: write runs-on: [runs-on,"runner=8cpu-linux-x64","image=ubuntu24-full-x64","run-id=${{ github.run_id }}",spot=false,extras=s3-cache] needs: [build, setup] - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_registry) }} steps: - uses: runs-on/action@v1 - uses: actions/checkout@v4