Skip to content

Commit

Permalink
ci: use extra job for checking if label was removed
Browse files Browse the repository at this point in the history
  • Loading branch information
radnov committed Oct 30, 2023
1 parent 3aadbab commit 8ed86a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
working-directory: scripts/instances
env:
EXPECTED_STATUS: Running
run: timeout 600 bash -ex -c 'while [[ "$(./status.sh dev $INSTANCE_NAME | jq -r)" != "$EXPECTED_STATUS" ]]; do echo "Instance is not $EXPECTED_STATUS yet ..."; sleep 5; done'
run: timeout 600 bash -ex -c 'until [[ "$(./status.sh dev $INSTANCE_NAME | jq -r)" == "$EXPECTED_STATUS" ]]; do echo "Instance is not $EXPECTED_STATUS yet ..."; sleep 5; done'

- name: Start analytics generation
run: curl -X POST -u "${{ secrets.DHIS2_USERNAME }}:${{ secrets.DHIS2_PASSWORD }}" "$INSTANCE_HOST/$INSTANCE_NAME/api/resourceTables/analytics" -d 'executeTei=true'
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/destroy-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ concurrency:
cancel-in-progress: true

jobs:
check-deploy-label:
runs-on: ubuntu-latest
outputs:
removed: ${{ steps.check.outputs.removed }}
steps:
- name: Check if "deploy" was removed
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
last_removed_label=$(
gh api "repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/events" \
--jq 'map(select(.event == "unlabeled"))[-1].label.name'
)
if [[ "$last_removed_label" == 'deploy' ]]; then
echo "removed=true" >> "$GITHUB_OUTPUT"
fi
destroy-instance:
if: contains(github.event.pull_request.labels.*.name, 'deploy')
needs: check-deploy-label
if: (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'deploy')) || needs.check-deploy-label.outputs.removed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit 8ed86a2

Please sign in to comment.