diff --git a/.github/workflows/set-automatic-deploys.yml b/.github/workflows/set-automatic-deploys.yml deleted file mode 100644 index 90fbfae34..000000000 --- a/.github/workflows/set-automatic-deploys.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Set automatic deploys - -on: - workflow_call: - inputs: - automaticDeploysEnabled: - description: 'Configures whether automatic deployments are enabled' - required: true - type: boolean - appName: - required: false - default: ${{ github.event.repository.name }} - type: string - environment: - description: 'Environment to modify' - required: false - default: 'integration' - type: string - secrets: - WEBHOOK_TOKEN: - required: true - WEBHOOK_URL: - required: true - GH_TOKEN: - required: true - -jobs: - set-automatic-deploys: - name: Set automatic deploys - runs-on: ubuntu-latest - steps: - - name: Check deploy permissions - id: deploy-permissions - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} - GITHUB_TEAM: gov-uk-production-deploy - GITHUB_USER: ${{ github.triggering_actor }} - run: | - TEAM_MEMBERSHIP=$(gh api "orgs/alphagov/teams/${GITHUB_TEAM}/memberships/${GITHUB_USER}" -q .state || echo false) - - if ! [[ "${TEAM_MEMBERSHIP}" = active || "${ENVIRONMENT}" = integration ]]; then - echo "::error title=Insufficient permissions to deploy::User ${GITHUB_USER} needs to be a member of the ${GITHUB_TEAM} team" - exit 1 - fi - - - name: Send webhook - if: steps.deploy-permissions.outcome == 'success' - env: - AUTOMATIC_DEPLOYS_ENABLED: ${{ inputs.automaticDeploysEnabled }} - ENVIRONMENT: ${{ inputs.environment }} - REPO_NAME: ${{ inputs.appName }} - WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }} - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - run: | - curl --fail-with-body --silent \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer ${WEBHOOK_TOKEN}" \ - -d "{ - \"environment\": \"${ENVIRONMENT}\", - \"repoName\": \"${REPO_NAME}\", - \"automaticDeploysEnabled\": \"${AUTOMATIC_DEPLOYS_ENABLED}\" - }" \ - "${WEBHOOK_URL}/set-automatic-deploys-enabled"