Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check dispatch #1068

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
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
176 changes: 10 additions & 166 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,188 +4,32 @@ on:
pull_request:
branches:
- master
types: [ closed ]

jobs:
createReleasePullRequest:
if: "!contains(join(github.event.pull_request.labels.*.name, ','), 'Release') && github.event.pull_request.merged == true"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Read .nvmrc
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Use Node.js (.nvmrc)
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Install Dependencies and Build Packages
run: make init
- name: Git Identity
run: |
git config --global user.name 'frontegg'
git config --global user.email '[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate with Registry
run: |
yarn logout
echo "init-author-name=Frontegg LTD" > .npmrc
echo "[email protected]" >> .npmrc
echo "init-author-url=https://frontegg.com" >> .npmrc
echo "init-license=MIT" >> .npmrc
echo "always-auth=true" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
echo "_authToken=$NPM_TOKEN" >> .npmrc
echo "@frontegg:registry=https://registry.npmjs.org" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Commit Version UP
run: |
yarn lerna version patch --no-git-tag-version --yes --no-push --force-publish
yarn update-version
yarn prettier-hook
- name: "Set Generated changelog"
uses: actions/github-script@v6
id: 'generated-changelog'
with:
result-encoding: string
script: |
const { generateChangeLog } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/index.js`);
return generateChangeLog({context, github, core})
- name: "Set incremented version"
uses: actions/github-script@v6
id: 'incremented-version'
with:
result-encoding: string
script: |
const {default: fs} = await import('fs');
const {version} = JSON.parse(fs.readFileSync('./lerna.json', {encoding: "utf-8"}));
return version;
- name: Commit changes
shell: bash -ex {0}
run: |
git add . && git commit -m "chore(release): publish ${{ steps.incremented-version.outputs.result }}"
- name: Create Release Pull Request
id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ secrets.GITHUB_WORKSPACE }}
commit-message: "Update v${{ steps.incremented-version.outputs.result }}"
committer: GitHub <[email protected]>
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
title: 'v${{ steps.incremented-version.outputs.result }}'
body: |
# v${{ steps.incremented-version.outputs.result }}

${{steps.generated-changelog.outputs.result}}

labels: "Type: Release"
branch: "release/next"

- name: Publish Pre-Release version to NPM
id: publish_pre_release_version
run: |
version=$(node -p 'require("./lerna.json").version')
echo "::set-output name=LIB_VERSION::${version}"
echo "Publishing DEV version - v${version}-alpha.${{ github.run_id }}"
make move-package-json-to-dist
make prerelease-version-upgrade-${version}-alpha.${{ github.run_id }}
make pretty
git add .
git commit -m "chore: prelrease version"
make publish-packages-next
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Notify Slack on alpha version deployment
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: frontegg-alpha-versions
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/67857107?s=40&v=4
SLACK_MESSAGE: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }} has been released :rocket:'
SLACK_TITLE: 'A new @frontegg/react alpha version!'
SLACK_USERNAME: ${{ github.actor }}
SLACK_WEBHOOK: ${{ secrets.ROTEM_SLACK_WEBHOOK }}
MSG_MINIMAL: true
- name: Wait until NPM registry finished indexing the new version
uses: actions/github-script@v6
with:
script: |
const checkingVersion = '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}';
const checkNpmVersions = require('./scripts/wait-for-npm-indexing.js');
await checkNpmVersions(github, ['@frontegg/react'], checkingVersion);

- name: "Trigger Oauth Service Pipeline Workflow"
uses: actions/github-script@v5
uses: actions/github-script@v7
env:
PR_VERSION: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}'
PR_VERSION: ''
with:
github-token : ${{ secrets.DISPATCH_WORKFLOWS_TOKEN }}
script: |
const fe_react_version= process.env.PR_VERSION;
const owner = context.payload.repository.organization
const oauthServiceRepo = 'oauth-service'
const workflow_id = 'update-react-dependency.yaml'

const fe_react_version = "test-alpha.${{ github.run_id }}";
const owner = 'frontegg';
const oauthServiceRepo = 'oauth-service';
const workflow_id = 'update-react-dependency.yaml';
const data = await github.rest.actions.createWorkflowDispatch({
owner,
repo: oauthServiceRepo,
workflow_id,
ref: 'master',
ref: "master",
inputs: {
fe_react_version,
}
});

- name: Prepare E2E test workflow
uses: actions/github-script@v5
env:
PR_REF: '${{ steps.cpr.outputs.pull-request-head-sha }}'
PR_VERSION: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}'
with:
script: |
const sha = process.env.PR_REF;
const repo = context.payload.repository.name
const owner = context.payload.repository.organization

const res = await github.rest.repos.createCommitStatus({
context, owner, repo, sha,
state: 'pending',
description: 'Dispatching E2E tests...',
});
- name: "Trigger E2E tests"
uses: actions/github-script@v5
env:
PR_REF: '${{ steps.cpr.outputs.pull-request-head-sha }}'
PR_VERSION: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}'
with:
github-token: ${{ secrets.E2E_WORKFLOW_TOKEN }}
script: |
const version = process.env.PR_VERSION;
const sha = process.env.PR_REF;
const repo = context.payload.repository.name

const owner = context.payload.repository.organization
const e2eRepo = 'e2e-system-tests'
const workflow_id = 'frontegg-react-e2e-tests.yml'
const context = `${owner}/${e2eRepo}`
const dispatch_id = `${repo}/${sha}`

const data = await github.rest.actions.createWorkflowDispatch({
owner,
repo:e2eRepo,
workflow_id,
ref: 'main',
inputs: {
version,
dispatch_id,
}
});


Loading