mirror of
https://github.com/ansible/awx.git
synced 2026-06-24 16:17:51 -02:30
Fix skip of push operations which are still failing in mirrors (#16468)
* Fix bash operator precedence in repo ownership check The condition had || operators outside proper test block grouping, which could cause the check to fail with a shell error. Wrap the OR conditions in parentheses with explicit [[ ]] tests. Assisted-by: Claude Haiku 4.5 <noreply@anthropic.com> * Replace reusable workflow with direct if conditions for repo ownership check The reusable workflow with job dependencies had a timing/evaluation issue where jobs would still execute even when should_run=false. Using direct if conditions with github context variables (repository, ref_name) is more reliable and ensures jobs are properly skipped on fork pushes. Assisted-by: Claude Haiku 4.5 <noreply@anthropic.com> * Remove unused repo-owns-branch reusable workflow No longer needed after replacing with direct if conditions. Assisted-by: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
55
.github/workflows/_repo-owns-branch.yml
vendored
55
.github/workflows/_repo-owns-branch.yml
vendored
@@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
name: Repo Owns Branch
|
|
||||||
|
|
||||||
# Reusable workflow that determines whether the current repository
|
|
||||||
# owns the current branch for push operations.
|
|
||||||
#
|
|
||||||
# Ownership rules:
|
|
||||||
# - ansible/awx owns: devel, feature_*
|
|
||||||
# - ansible/tower owns: stable-*, release_*
|
|
||||||
# - workflow_dispatch is always allowed
|
|
||||||
#
|
|
||||||
# All other repo/branch combinations are skipped.
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
outputs:
|
|
||||||
should_run:
|
|
||||||
description: Whether this repo owns the current branch
|
|
||||||
value: ${{ jobs.check.outputs.should_run }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
should_run: ${{ steps.check.outputs.should_run }}
|
|
||||||
steps:
|
|
||||||
- name: Check branch ownership
|
|
||||||
id: check
|
|
||||||
run: |
|
|
||||||
REPO="${{ github.repository }}"
|
|
||||||
BRANCH="${{ github.ref_name }}"
|
|
||||||
EVENT="${{ github.event_name }}"
|
|
||||||
|
|
||||||
if [[ "$EVENT" == "workflow_dispatch" ]]; then
|
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Manual trigger — allowed"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ansible/awx owns devel and feature_* branches
|
|
||||||
if [[ "$REPO" == "ansible/awx" ]] && [[ "$BRANCH" == "devel" || "$BRANCH" == feature_* ]]; then
|
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Repository '$REPO' owns branch '$BRANCH'"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ansible/tower owns stable-* and release_* branches
|
|
||||||
if [[ "$REPO" == "ansible/tower" ]] && [[ "$BRANCH" == stable-* || "$BRANCH" == release_* ]]; then
|
|
||||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Repository '$REPO' owns branch '$BRANCH'"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
|
||||||
echo "Repository '$REPO' does not own branch '$BRANCH' — skipping"
|
|
||||||
9
.github/workflows/devel_images.yml
vendored
9
.github/workflows/devel_images.yml
vendored
@@ -12,12 +12,11 @@ on:
|
|||||||
- feature_*
|
- feature_*
|
||||||
- stable-*
|
- stable-*
|
||||||
jobs:
|
jobs:
|
||||||
check-ownership:
|
|
||||||
uses: ./.github/workflows/_repo-owns-branch.yml
|
|
||||||
|
|
||||||
push-development-images:
|
push-development-images:
|
||||||
needs: check-ownership
|
if: |
|
||||||
if: needs.check-ownership.outputs.should_run == 'true'
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
(github.repository == 'ansible/awx' && (github.ref_name == 'devel' || startsWith(github.ref_name, 'feature_'))) ||
|
||||||
|
(github.repository == 'ansible/tower' && (startsWith(github.ref_name, 'stable-') || startsWith(github.ref_name, 'release_')))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
9
.github/workflows/spec-sync-on-merge.yml
vendored
9
.github/workflows/spec-sync-on-merge.yml
vendored
@@ -20,12 +20,11 @@ on:
|
|||||||
- 'stable-2.[1-9][0-9]'
|
- 'stable-2.[1-9][0-9]'
|
||||||
workflow_dispatch: # Allow manual triggering for testing
|
workflow_dispatch: # Allow manual triggering for testing
|
||||||
jobs:
|
jobs:
|
||||||
check-ownership:
|
|
||||||
uses: ./.github/workflows/_repo-owns-branch.yml
|
|
||||||
|
|
||||||
sync-openapi-spec:
|
sync-openapi-spec:
|
||||||
needs: check-ownership
|
if: |
|
||||||
if: needs.check-ownership.outputs.should_run == 'true'
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
(github.repository == 'ansible/awx' && (github.ref_name == 'devel' || startsWith(github.ref_name, 'feature_'))) ||
|
||||||
|
(github.repository == 'ansible/tower' && (startsWith(github.ref_name, 'stable-') || startsWith(github.ref_name, 'release_')))
|
||||||
name: Sync OpenAPI spec to central repo
|
name: Sync OpenAPI spec to central repo
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
9
.github/workflows/upload_schema.yml
vendored
9
.github/workflows/upload_schema.yml
vendored
@@ -13,12 +13,11 @@ on:
|
|||||||
- feature_**
|
- feature_**
|
||||||
- stable-**
|
- stable-**
|
||||||
jobs:
|
jobs:
|
||||||
check-ownership:
|
|
||||||
uses: ./.github/workflows/_repo-owns-branch.yml
|
|
||||||
|
|
||||||
push:
|
push:
|
||||||
needs: check-ownership
|
if: |
|
||||||
if: needs.check-ownership.outputs.should_run == 'true'
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
(github.repository == 'ansible/awx' && (github.ref_name == 'devel' || startsWith(github.ref_name, 'feature_'))) ||
|
||||||
|
(github.repository == 'ansible/tower' && (startsWith(github.ref_name, 'stable-') || startsWith(github.ref_name, 'release_')))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
Reference in New Issue
Block a user