feat: Add defaults to optionSetItem [DHIS2-18643] #2145
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Destroy instance | |
on: | |
pull_request: | |
types: [closed, unlabeled] | |
# Cancel previous runs of the same workflow and PR number or branch/tag | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
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: | |
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: | |
- name: 'Get latest IM tag' | |
id: latest-im-tag | |
run: | | |
LATEST_IM_TAG=$(git ls-remote --tags --sort='v:refname' https://github.com/dhis2-sre/im-manager | tail -1 | awk '{print $2}') | |
echo "LATEST_IM_TAG=$LATEST_IM_TAG" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
repository: dhis2-sre/im-manager | |
ref: ${{ env.LATEST_IM_TAG }} | |
sparse-checkout: scripts/instances | |
- name: Install HTTPie | |
run: python -m pip install httpie | |
- name: Destroy DHIS2 instance | |
working-directory: scripts/instances | |
env: | |
HTTP: https --check-status | |
USER_EMAIL: ${{ secrets.IM_BOT_EMAIL }} | |
PASSWORD: ${{ secrets.IM_BOT_PASSWORD }} | |
IM_HOST: 'https://api.im.dhis2.org' | |
INSTANCE_NAME: pr-${{ github.event.number }} | |
run: ./findByName.sh dev $INSTANCE_NAME && ./destroy-deployment.sh $(./findByName.sh dev $INSTANCE_NAME | jq -r '.id') | |
- name: Delete instance URL comment | |
uses: actions-cool/maintain-one-comment@v3 | |
with: | |
body: "Instance deployed to https://dev.im.dhis2.org/pr-${{ github.event.pull_request.number }}" | |
delete: true |