diff --git a/.github/workflows/main-push.yml b/.github/workflows/main-push.yml index 76d119b..aa35df4 100644 --- a/.github/workflows/main-push.yml +++ b/.github/workflows/main-push.yml @@ -28,31 +28,30 @@ jobs: runs-on: ubuntu-latest needs: release steps: - - name: Check for initialized - id: file_check - run: | - if ls -l catalogs | wc -l != 0; then - echo "check_result=true" >> $GITHUB_OUTPUT - else - echo "check_result=false" >> $GITHUB_OUTPUT - fi - name: Clone branch - if: steps.file_check.outputs.check_result == 'true' uses: actions/checkout@v2 with: fetch-depth: 0 ref: main token: ${{ secrets.GIT_TOKEN }} + - name: Determine initialization status + id: determine_initialization_status + run: | + set +e + bash scripts/automation/check_catalog.sh + exitcode="$?" + echo "exitcode: $exitcode" + echo "exitcode=$exitcode" >> $GITHUB_OUTPUT - name: Clone downstream repo - if: steps.file_check.outputs.check_result == 'true' + if: steps.determine_initialization_status.outputs.exitcode == '1' uses: actions/checkout@v2 with: - repository: my-repo-base/my-profile - path: './my-profile' + repository: degenaro/acme-profile-nist-800-53 + path: 'acme-profile-nist-800-53' token: ${{ secrets.GIT_TOKEN }} fetch-depth: 0 - name: Update profiles - if: steps.file_check.outputs.check_result == 'true' + if: steps.determine_initialization_status.outputs.exitcode == '1' run: bash scripts/automation/update_downstream.sh env: GH_TOKEN: ${{ secrets.GIT_TOKEN }} diff --git a/scripts/automation/check_catalog.sh b/scripts/automation/check_catalog.sh new file mode 100755 index 0000000..fd378ec --- /dev/null +++ b/scripts/automation/check_catalog.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source config.env + +RESULT=$(ls catalogs) + +if [[ "$RESULT" == *"$CATALOG"* ]]; then + echo "catalog exists, exit 1"; + exit 1; +else + echo "catalog does not exist, exit 0" + exit 0; +fi