forked from salute-developers/plasma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,53 +19,3 @@ jobs: | |
secrets: | ||
gh_token: ${{ secrets.GH_TOKEN }} | ||
npm_registry_token: ${{ secrets.NPM_REGISTRY_TOKEN }} | ||
|
||
changelog: | ||
runs-on: ubuntu-latest | ||
needs: [publish] | ||
if: ${{ always() && contains(needs.*.result, 'success') }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.gh_token }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
fetch-depth: 0 | ||
|
||
- name: Get associated pull request by commit | ||
id: data | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const res = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
commit_sha: context.sha, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const data = res?.data[0].body || ''; | ||
return data; | ||
- name: Install dependencies | ||
run: | | ||
cd .github/actions/write-changelog | ||
npm ci | ||
- name: Write changelog | ||
uses: ./.github/actions/write-changelog | ||
with: | ||
token: ${{ secrets.gh_token }} | ||
data: ${{ steps.data.outputs.result }} | ||
|
||
- name: Commit & Push changelog files | ||
uses: actions-js/push@master | ||
with: | ||
github_token: ${{ secrets.gh_token }} | ||
message: 'chore: Update CHANGELOG.md [skip ci]' | ||
branch: master | ||
author_name: Salute Frontend Team | ||
author_email: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,68 +6,9 @@ on: | |
- dev | ||
|
||
jobs: | ||
state: | ||
if: ${{ github.actor == 'github-merge-queue[bot]' }} | ||
name: State | ||
runs-on: ubuntu-22.04 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
outputs: | ||
PR: ${{ steps.pull_request.outputs.result }} | ||
steps: | ||
## Получаем актуальное состояние dev branch | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
fetch-depth: 0 | ||
|
||
- name: Prepare environment | ||
uses: ./.github/actions/prepare-environment | ||
|
||
## Получаем информацию о pull request который был влит | ||
## context.sha - это последний commit в dev ветку | ||
## base.sha - это последний commit base branch до влития целевого pull request | ||
- name: Get associated pull request by commit | ||
id: pull_request | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const teammate = { | ||
Yakutoc: "alex_czech", | ||
'neretin-trike': "aaneretin", | ||
'Yeti-or': "yeti-or", | ||
TitanKuzmich: "aakrivonos", | ||
kayman233: "ivakudryavtsev", | ||
shuga2704: "shuga2704", | ||
}; | ||
const res = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
commit_sha: context.sha, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const { | ||
base: { sha = context.sha }, | ||
title, | ||
user: { login } | ||
} = res?.data[0] || {}; | ||
return { sha, pr: title, user: teammate[login] || 'alex_czech' }; | ||
## Сохраняем вывод команды lerna ls в формате json array | ||
- name: Preserve lerna ls state | ||
id: lerna_ls | ||
env: | ||
SHA: ${{ fromJSON(steps.pull_request.outputs.result).sha }} | ||
run: | | ||
echo "RAW_DATA=$(npx lerna la --json --since=${{ env.SHA }} | jq -c)" >> "$GITHUB_OUTPUT" | ||
publish: | ||
if: false | ||
name: Publish RC version | ||
needs: [ state ] | ||
if: ${{ github.actor == 'github-merge-queue[bot]' }} | ||
uses: ./.github/workflows/publish-common.yml | ||
with: | ||
with-update-package-lock: true | ||
|
@@ -76,48 +17,52 @@ jobs: | |
secrets: | ||
gh_token: ${{ secrets.GH_TOKEN }} | ||
npm_registry_token: ${{ secrets.NPM_REGISTRY_TOKEN }} | ||
|
||
catch: | ||
name: Handle errors | ||
runs-on: ubuntu-22.04 | ||
needs: [ state, publish ] | ||
if: ${{ always() && contains(needs.*.result, 'failure') }} | ||
env: | ||
FAILED_JOB_NAME: ${{ contains(needs.change-state.result, 'failure') && 'State' || 'Publish RC version / publish' }} | ||
TITLE: ${{ fromJSON(needs.state.outputs.PR).pr }} | ||
USER: ${{ fromJSON(needs.state.outputs.PR).user }} | ||
steps: | ||
- name: Get failed job information | ||
id: job | ||
uses: actions/github-script@v6 | ||
env: | ||
RUN_ID: ${{github.run_id}} | ||
FAILED_JOB_NAME: ${{ env.FAILED_JOB_NAME }} | ||
with: | ||
script: | | ||
const { RUN_ID, FAILED_JOB_NAME } = process.env; | ||
const res = await github.rest.actions.listJobsForWorkflowRun({ | ||
run_id: RUN_ID, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const { data: { jobs: jobsList } } = res; | ||
const { html_url, steps: stepsList } = jobsList.find(({ name }) => name === FAILED_JOB_NAME ) || {}; | ||
const { name } = stepsList.find(({ conclusion }) => conclusion === "failure" ) || { name: '' }; | ||
return { job: html_url, name } | ||
- name: Send notification about failure state | ||
uses: mattermost/action-mattermost-notify@master | ||
with: | ||
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOKS_NOTIFICATIONS_MM }} | ||
TEXT: | | ||
Публикация RC 💀 | ||
**PR**: ${{ env.TITLE }} | ||
**Failure step**: [${{ fromJSON(steps.job.outputs.result).name }}](${{ fromJSON(steps.job.outputs.result).job }}) | ||
**Автор**: @${{ env.USER }} | ||
|
||
changelog: | ||
runs-on: ubuntu-latest | ||
needs: [publish] | ||
if: ${{ always() && contains(needs.*.result, 'success') }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.gh_token }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
fetch-depth: 0 | ||
|
||
- name: Get associated pull request by commit | ||
id: data | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const res = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
commit_sha: context.sha, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const data = res?.data[0].body || ''; | ||
return data; | ||
- name: Install dependencies | ||
run: | | ||
cd .github/actions/write-changelog | ||
npm ci | ||
- name: Write changelog | ||
uses: ./.github/actions/write-changelog | ||
with: | ||
token: ${{ secrets.gh_token }} | ||
data: ${{ steps.data.outputs.result }} | ||
|
||
- name: Commit & Push changelog files | ||
uses: actions-js/push@master | ||
with: | ||
github_token: ${{ secrets.gh_token }} | ||
message: 'chore: Update CHANGELOG.md [skip ci]' | ||
branch: dev | ||
author_name: Salute Frontend Team | ||
author_email: [email protected] |