Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

INT-8299: adding integration project support for auto #599

Merged
merged 5 commits into from
May 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/integration-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: J1 Google Cloud Integration deployment

on:
release:
types:
- published

jobs:
j1-integration-deployment:
runs-on: ubuntu-latest
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/[email protected]
with:
script: |
const tagName = context.payload.release.tag_name
const versionNumber = tagName.replace("v", "")
core.setOutput('versionNumber', versionNumber)
core.setOutPut('integrationName', 'integration-google-cloud')
core.setOutPut('graphProjectName', 'google-cloud')
Copy link
Contributor

@Nick-NCSU Nick-NCSU May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
core.setOutPut('integrationName', 'integration-google-cloud')
core.setOutPut('graphProjectName', 'google-cloud')
core.setOutput('integrationName', 'integration-google-cloud')
core.setOutput('graphProjectName', 'google-cloud')

Or to avoid using the deprecated core.setOutput more I would recommend removing these 2 lines and on line 8 using

jobs:
  j1-integration-deployment:
    runs-on: ubuntu-latest
    env:
      IntegrationName: integration-google-cloud
      GraphProjectName: google-cloud

and you can refer to them with $IntegrationName and $GraphProjectName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Nick-NCSU , committing suggested changes.


- name: Clone integration-google-cloud repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
repository: JupiterOne/${{ steps.set_constants.outputs.integrationName }}
ref: main
path: './${{ steps.set_constants.outputs.integrationName }}'
- name: Set git config
shell: bash
working-directory: ./${{ steps.set_constants.outputs.integrationName }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "j1-internal-automation"
- name: Clean up and create branch
shell: bash
working-directory: ./${{ steps.set_constants.outputs.integrationName }}
run: |
git reset --hard
git checkout -b deploy-${{ steps.set_constants.outputs.integrationName }}-${{ steps.set_constants.outputs.versionNumber }}
git push origin deploy-${{ steps.set_constants.outputs.integrationName }}-${{ steps.set_constants.outputs.versionNumber }}
- name: Bump version in package.json and commit changes
shell: bash
working-directory: ./${{ steps.set_constants.outputs.integrationName }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > .npmrc
yarn
yarn upgrade @jupiterone/graph-${{ steps.set_constants.outputs.graphProjectName || steps.set_constants.outputs.integrationName }}@^${{ steps.set_constants.outputs.versionNumber }}
git add .
git commit -m "bump ${{ steps.set_constants.outputs.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: ./${{ steps.set_constants.outputs.integrationName }}
branch: deploy-${{ steps.set_constants.outputs.integrationName }}-${{ steps.set_constants.outputs.versionNumber }}
base: main
title: "[Github Action][${{ steps.set_constants.outputs.integrationName }}] - Deploy graph-${{ steps.set_constants.outputs.graphProjectName || steps.set_constants.outputs.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 ${{ steps.set_constants.outputs.integrationName }}
- name: Enable Automerge
if: steps.create_pull_request.outputs.pull-request-operation == 'created'
shell: bash
run: gh pr merge --squash --auto "${{ steps.create_pull_request.outputs.pull-request-url }}"
sl45082 marked this conversation as resolved.
Show resolved Hide resolved
env:
GH_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}