From 5109e57ff46c7672a912d0098dabe3a9f5c4e9ba Mon Sep 17 00:00:00 2001 From: Lukas Gravley Date: Wed, 10 Mar 2021 08:36:46 -0600 Subject: [PATCH] adding dope code (#1333) * adding dope code * fix contains logic --- .github/workflows/deploy-PROD.yml | 122 +++++++++++++++++++++++++++ .github/workflows/deploy-RELEASE.yml | 5 +- 2 files changed, 125 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-PROD.yml b/.github/workflows/deploy-PROD.yml index 067d6839..1c76d944 100644 --- a/.github/workflows/deploy-PROD.yml +++ b/.github/workflows/deploy-PROD.yml @@ -70,6 +70,36 @@ jobs: username: ${{ secrets.GCR_USERNAME }} password: ${{ secrets.GCR_TOKEN }} + ######################### + # Update deployment API # + ######################### + - name: Start deployment + uses: bobheadxi/deployments@v0.4.3 + id: deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: Production + + ####################################################### + # Create a GitHub Issue with the info from this build # + ####################################################### + - name: Create GitHub Issue + uses: actions/github-script@v3.1.0 + id: create-issue + with: + # https://octokit.github.io/rest.js/v18#issues-create + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const create = await github.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: "Deploying to production", + body: 'Currently deploying...' + }) + console.log('create', create) + return create.data.number + ########################################### # Build and Push containers to registries # ########################################### @@ -88,3 +118,95 @@ jobs: github/super-linter:v3 ghcr.io/github/super-linter:latest ghcr.io/github/super-linter:v3 + + ######################################## + # Update the issue with success status # + ######################################## + - name: Update issue success + uses: actions/github-script@v3.1.0 + if: success() + with: + # https://octokit.github.io/rest.js/v18#issues-create + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: "${{ steps.create-issue.outputs.result }}", + title: "New issue created", + body: "Successfuly deployed to production" + }) + + ############################ + # Close issue from success # + ############################ + - name: Close issue success + uses: actions/github-script@v3.1.0 + if: success() + with: + # https://octokit.github.io/rest.js/v18#issues-create + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: "${{ steps.create-issue.outputs.result }}", + state: "closed" + }) + + + ######################################## + # Update the issue with failure status # + ######################################## + - name: Update issue failure + uses: actions/github-script@v3.1.0 + if: failure() + with: + # https://octokit.github.io/rest.js/v18#issues-create + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: "${{ steps.create-issue.outputs.result }}", + title: "New issue created", + body: "Failed to deploy to production" + }) + + ############################ + # Assign admins on failure # + ############################ + - name: Assign Admins on failure + uses: actions/github-script@v3.1.0 + if: failure() + with: + # https://octokit.github.io/rest.js/v18#issues-create + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.addAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: "${{ steps.create-issue.outputs.result }}", + assignees: [ + 'admiralawkbar', + 'jwiebalk', + 'IAmHughes', + 'nemchik', + 'Hanse00', + 'GaboFDC', + 'ferrarimarco' + ] + }) + + ######################### + # Update Deployment API # + ######################### + - name: Update deployment status + uses: bobheadxi/deployments@v0.4.3 + if: always() + with: + step: finish + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + env_url: https://github.com/github/super-linter diff --git a/.github/workflows/deploy-RELEASE.yml b/.github/workflows/deploy-RELEASE.yml index dedc6e6f..5ec3b4c3 100644 --- a/.github/workflows/deploy-RELEASE.yml +++ b/.github/workflows/deploy-RELEASE.yml @@ -32,7 +32,8 @@ jobs: # Delete the created issue as it was created by someone # # who is not authorized to create a release # ######################################################### - if: contains(github.event.issue.title, 'Super-Linter Release:') && + if: contains(github.event.issue.title, 'Super-Linter') && + contains(github.event.issue.title, 'Release:') && github.actor != 'admiralawkbar' || github.actor != 'jwiebalk' || github.actor != 'IAmHughes' || github.actor != 'nemchik' || github.actor != 'Hanse00' || github.actor != 'github-actions' || @@ -252,4 +253,4 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} status: ${{ job.status }} deployment_id: ${{ steps.deployment.outputs.deployment_id }} - env_url: https://github.com/orgs/${{github.repository_owner}}/container/package/${{github.repository.name}} + env_url: https://github.com/github/super-linter/releases/tag/${{ env.RELEASE_VERSION }}