|
7 | 7 | required: false |
8 | 8 | default: '' |
9 | 9 | type: string |
| 10 | + force_build_deps: |
| 11 | + description: 'Force build forcingprocessor-deps (provide tag version, e.g., 1.0.0)' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + type: string |
| 15 | + force_build_fp: |
| 16 | + description: 'Force build forcingprocessor (provide tag version, e.g., 1.0.0)' |
| 17 | + required: false |
| 18 | + default: '' |
| 19 | + type: string |
10 | 20 | push: |
11 | 21 | branches: |
12 | 22 | - main |
@@ -46,11 +56,42 @@ jobs: |
46 | 56 | shell: bash |
47 | 57 | run: | |
48 | 58 | set -euo pipefail |
49 | | - |
| 59 | +
|
| 60 | + # Check for manual trigger with forced builds |
| 61 | + FORCE_DEPS="${{ inputs.force_build_deps }}" |
| 62 | + FORCE_FP="${{ inputs.force_build_fp }}" |
| 63 | +
|
| 64 | + if [ -n "$FORCE_DEPS" ] || [ -n "$FORCE_FP" ]; then |
| 65 | + echo "Manual trigger with forced build detected" |
| 66 | +
|
| 67 | + if [ -n "$FORCE_DEPS" ]; then |
| 68 | + echo "Force building forcingprocessor-deps with tag: $FORCE_DEPS" |
| 69 | + echo "build_deps=true" >> "$GITHUB_OUTPUT" |
| 70 | + echo "deps_version=$FORCE_DEPS" >> "$GITHUB_OUTPUT" |
| 71 | + else |
| 72 | + echo "build_deps=false" >> "$GITHUB_OUTPUT" |
| 73 | + CURRENT_DEPS=$(yq -r e '."forcingprocessor-deps"' versions.yml) |
| 74 | + echo "deps_version=$CURRENT_DEPS" >> "$GITHUB_OUTPUT" |
| 75 | + fi |
| 76 | +
|
| 77 | + if [ -n "$FORCE_FP" ]; then |
| 78 | + echo "Force building forcingprocessor with tag: $FORCE_FP" |
| 79 | + echo "build_fp=true" >> "$GITHUB_OUTPUT" |
| 80 | + echo "fp_version=$FORCE_FP" >> "$GITHUB_OUTPUT" |
| 81 | + else |
| 82 | + echo "build_fp=false" >> "$GITHUB_OUTPUT" |
| 83 | + CURRENT_FP=$(yq -r e '.forcingprocessor' versions.yml) |
| 84 | + echo "fp_version=$CURRENT_FP" >> "$GITHUB_OUTPUT" |
| 85 | + fi |
| 86 | +
|
| 87 | + exit 0 |
| 88 | + fi |
| 89 | +
|
| 90 | + # Normal version change detection for push/PR events |
50 | 91 | # Current versions (raw) |
51 | 92 | CURRENT_DEPS=$(yq -r e '."forcingprocessor-deps"' versions.yml) |
52 | 93 | CURRENT_FP=$(yq -r e '.forcingprocessor' versions.yml) |
53 | | - |
| 94 | +
|
54 | 95 | # Ensure previous commit and file exist |
55 | 96 | if git rev-parse HEAD~1 >/dev/null 2>&1 && git cat-file -e HEAD~1:versions.yml 2>/dev/null; then |
56 | 97 | git show HEAD~1:versions.yml > previous_versions.yml |
|
60 | 101 |
|
61 | 102 | PREVIOUS_DEPS=$(yq -r e '."forcingprocessor-deps"' previous_versions.yml) |
62 | 103 | PREVIOUS_FP=$(yq -r e '.forcingprocessor' previous_versions.yml) |
63 | | - |
| 104 | +
|
64 | 105 | # Check what changed and set outputs |
65 | 106 | if [ "$CURRENT_DEPS" != "$PREVIOUS_DEPS" ]; then |
66 | 107 | echo "forcingprocessor-deps changed: $PREVIOUS_DEPS -> $CURRENT_DEPS" |
|
69 | 110 | echo "build_deps=false" >> "$GITHUB_OUTPUT" |
70 | 111 | fi |
71 | 112 | echo "deps_version=$CURRENT_DEPS" >> "$GITHUB_OUTPUT" |
72 | | - |
| 113 | +
|
73 | 114 | if [ "$CURRENT_FP" != "$PREVIOUS_FP" ]; then |
74 | 115 | echo "forcingprocessor changed: $PREVIOUS_FP -> $CURRENT_FP" |
75 | 116 | echo "build_fp=true" >> "$GITHUB_OUTPUT" |
@@ -141,14 +182,14 @@ jobs: |
141 | 182 | retention-days: 10 |
142 | 183 |
|
143 | 184 | - name: Login to Docker Hub |
144 | | - if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 185 | + if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && (inputs.force_build_deps != '' || inputs.force_build_fp != '')) |
145 | 186 | uses: docker/login-action@v3 |
146 | 187 | with: |
147 | 188 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
148 | 189 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
149 | 190 |
|
150 | 191 | - name: Push docker containers |
151 | | - if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 192 | + if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && (inputs.force_build_deps != '' || inputs.force_build_fp != '')) |
152 | 193 | run: | |
153 | 194 | if [ "${{ needs.detect-changes.outputs.build_deps }}" == "true" ]; then |
154 | 195 | VERSION_TAG="${{ needs.detect-changes.outputs.deps_version }}" |
@@ -356,7 +397,7 @@ jobs: |
356 | 397 | create-manifest: |
357 | 398 | name: Create and Push Manifest |
358 | 399 | needs: [detect-changes, build-test-push-docker-arm] |
359 | | - if: github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.detect-changes.outputs.build_deps == 'true' || needs.detect-changes.outputs.build_fp == 'true') |
| 400 | + if: ((github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch') && (needs.detect-changes.outputs.build_deps == 'true' || needs.detect-changes.outputs.build_fp == 'true') |
360 | 401 | runs-on: ubuntu-latest |
361 | 402 | steps: |
362 | 403 | - name: Log in to Docker Hub |
|
0 commit comments