diff options
| -rw-r--r-- | .github/actions/deploy-status/action.yml | 36 | ||||
| -rwxr-xr-x | .github/actions/deploy-status/request.sh | 27 | ||||
| -rw-r--r-- | .github/workflows/deploy.yml | 23 |
3 files changed, 86 insertions, 0 deletions
diff --git a/.github/actions/deploy-status/action.yml b/.github/actions/deploy-status/action.yml new file mode 100644 index 000000000..90c9b50d8 --- /dev/null +++ b/.github/actions/deploy-status/action.yml @@ -0,0 +1,36 @@ +name: "deployment-status" +author: "menny" +description: "updates deployment status" + +inputs: + deployment_id: + description: "deployment-id" + required: true + state: + description: "commit to deploy" + required: true + environment: + description: "environment to deploy" + required: true + api_user_name: + description: "the username to use for API calls" + required: true + api_user_token: + description: "the user API token to use for API calls" + required: true + +runs: + using: "docker" + image: "docker://menny/ndk_ask:1.13.5" + entrypoint: /bin/bash + args: + - .github/actions/deploy-status/request.sh + - ${{ inputs.deployment_id }} + - ${{ inputs.state }} + - ${{ inputs.environment }} + - ${{ inputs.api_user_name }} + - ${{ inputs.api_user_token }} + +branding: + icon: 'package' + color: 'purple' diff --git a/.github/actions/deploy-status/request.sh b/.github/actions/deploy-status/request.sh new file mode 100755 index 000000000..eb2fdab4a --- /dev/null +++ b/.github/actions/deploy-status/request.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e + +ID="${1}" +ENVIRONMENT="${2}" +STATE="${3}" +API_USERNAME="${4}" +API_TOKEN="${5}" + +echo "making request to: ${ID} @ ${ENVIRONMENT} to state ${STATE}" +JSON_TEXT=$( jq -n \ + --arg jsonEnvironment "${ENVIRONMENT}" \ + --arg jsonState "${STATE}" \ + '{ environment: $jsonEnvironment, state: $jsonState }' ) + +JSON_FILENAME="${OUTPUT}/deployment_request.json" +echo "${JSON_TEXT}" > "${JSON_FILENAME}" +cat "${JSON_FILENAME}" +set +e +curl --fail -u "${API_USERNAME}:${API_TOKEN}" -o "${OUTPUT}/deployment_response.json" -d "@${JSON_FILENAME}" -H "Accept: application/vnd.github.flash-preview+json" "https://api.github.com/repos/AnySoftKeyboard/AnySoftKeyboard/deployments/${ID}/statuses" +curl_exit_code=$? +set -e +echo "response with exit-code ${curl_exit_code}:" +cat "${OUTPUT}/deployment_response.json" +if [[ ${curl_exit_code} -ne 0 ]]; then + exit ${curl_exit_code} +fi diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c7fb02417..9d156ad33 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,6 +22,13 @@ jobs: with: name: github_object path: build/github_object + - uses: ./.github/actions/deploy-status + with: + deployment_id: ${{ github.ref }} + state: in_progress + environment: ${{ github.event.deployment.environment }} + api_user_name: ${{ secrets.BOT_MASTER_RW_GITHUB_USERNAME }} + api_user_token: ${{ secrets.BOT_MASTER_RW_GITHUB_TOKEN }} - name: setup run: ./scripts/ci/ci_setup.sh - uses: ./.github/actions/deploy @@ -33,6 +40,22 @@ jobs: keystore_key_password: ${{ secrets.ANYSOFTKEYBOARD_KEYSTORE_KEY_PASSWORD }} publish_service_account_creds_url: ${{ secrets.PUBLISH_CERT_FILE_URL }} publish_service_account: ${{ secrets.PUBLISH_APK_SERVICE_ACCOUNT_EMAIL }} + - uses: ./.github/actions/deploy-status + if: success() + with: + deployment_id: ${{ github.ref }} + state: success + environment: ${{ github.event.deployment.environment }} + api_user_name: ${{ secrets.BOT_MASTER_RW_GITHUB_USERNAME }} + api_user_token: ${{ secrets.BOT_MASTER_RW_GITHUB_TOKEN }} + - uses: ./.github/actions/deploy-status + if: failure() + with: + deployment_id: ${{ github.ref }} + state: failure + environment: ${{ github.event.deployment.environment }} + api_user_name: ${{ secrets.BOT_MASTER_RW_GITHUB_USERNAME }} + api_user_token: ${{ secrets.BOT_MASTER_RW_GITHUB_TOKEN }} - uses: actions/upload-artifact@v1.0.0 with: name: apks |
