Skip to content

Commit

Permalink
devops: add success flag for first job
Browse files Browse the repository at this point in the history
  • Loading branch information
dg1223 committed Jul 26, 2023
1 parent 9f45d5c commit ef93a77
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/ci-cd-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ on:

jobs:
# Don't run CI/CD if only README.md is updated
check_readme_changes:
check_readme_yml_changes:
runs-on: ubuntu-latest
outputs:
run_rest_jobs: ${{ steps.set_output.outputs.run_jobs }}

steps:
- name: Checkout branch
Expand All @@ -17,22 +19,26 @@ jobs:
fetch-depth: 0

- name: Check for README changes
id: check-readme-changes
id: set_output
run: |
# Get the list of changed files between the base and head branches
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo ${CHANGED_FILES}
echo ${CHANGED_FILES}
# Check if 'README.md' or '.yml' files are the only files changed
if [[ ${CHANGED_FILES} =~ ^(README\.md|.*\.yml)$ && ! ${CHANGED_FILES} =~ ^(?!.*(README\.md|.*\.yml)).*$ ]]; then
echo "Only README.md or .yml files have been updated. Skipping the CI/CD workflow."
return 0
echo "::set-output name=run_jobs::false"
else
echo "Changes to files other than README.md or *.yml detected. Proceeding with the CI/CD workflow."
echo "::set-output name=run_jobs::true"
fi
echo "Changes to files other than README.md or *.yml detected. Proceeding with the CI/CD workflow."
# continue-on-error: true

test:
needs: check_readme_changes
needs: check_readme_yml_changes
if: needs.check_readme_yml_changes.outputs.run_rest_jobs == 'true'
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -72,8 +78,7 @@ jobs:

deploy:
needs: test
# default action is success()
# if: success()
# default action is success(): if(success)
runs-on: ubuntu-latest
env:
MYAPP_UPLOAD_KEY_ALIAS: ${{ secrets.ANDROID_SIGNING_ALIAS }}
Expand Down

0 comments on commit ef93a77

Please sign in to comment.