diff --git a/.github/workflows/integration-deployment.yml b/.github/workflows/integration-deployment.yml new file mode 100644 index 00000000..82206589 --- /dev/null +++ b/.github/workflows/integration-deployment.yml @@ -0,0 +1,76 @@ +name: J1 Google Cloud Integration deployment + +on: + release: + types: + - published + +jobs: + j1-integration-deployment: + runs-on: ubuntu-latest + env: + IntegrationName: integration-google-cloud + GraphProjectName: google-cloud + steps: + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Get graph project, integration name and version number + id: set_constants + uses: actions/github-script@0.9.0 + with: + script: | + const tagName = context.payload.release.tag_name + const versionNumber = tagName.replace("v", "") + core.setOutput('versionNumber', versionNumber) + - name: Clone integration-google-cloud repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} + repository: JupiterOne/${{ env.IntegrationName }} + ref: main + path: './${{ env.IntegrationName }}' + - name: Set git config + shell: bash + working-directory: ./${{ env.IntegrationName }} + run: | + git config --local user.email "internal-automation.bot@jupiterone.com" + git config --local user.name "j1-internal-automation" + - name: Clean up and create branch + shell: bash + working-directory: ./${{ env.IntegrationName }} + run: | + git reset --hard + git checkout -b deploy-${{ env.IntegrationName }}-${{ steps.set_constants.outputs.versionNumber }} + git push origin deploy-${{ env.IntegrationName }}-${{ steps.set_constants.outputs.versionNumber }} + - name: Bump version in package.json and commit changes + shell: bash + working-directory: ./${{ env.IntegrationName }} + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > .npmrc + yarn + yarn upgrade @jupiterone/graph-${{ env.GraphProjectName || env.IntegrationName }}@^${{ steps.set_constants.outputs.versionNumber }} + git add . + git commit -m "bump ${{ env.IntegrationName }} to version ${{ steps.set_constants.outputs.versionNumber }} deploy2dev" + - name: Create Pull Request + id: create_pull_request + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} + path: ./${{ env.IntegrationName }} + branch: deploy-${{ env.IntegrationName }}-${{ steps.set_constants.outputs.versionNumber }} + base: main + title: "[Github Action][${{ env.IntegrationName }}] - Deploy graph-${{ env.GraphProjectName || env.IntegrationName }} v${{ steps.set_constants.outputs.versionNumber }}" + body: | + ## Summary + ${{ github.event.release.body }} + Pull request created by [Github action](integration-deployment.yml). + PR to bump the version ${{ steps.set_constants.outputs.versionNumber }} for the integration ${{ env.IntegrationName }} + - name: Enable Automerge + if: steps.create_pull_request.outputs.pull-request-operation == 'created' + shell: bash + run: gh pr merge --merge --auto "${{ steps.create_pull_request.outputs.pull-request-url }}" + env: + GH_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}