Skip to content

Update versions

Update versions #658

Workflow file for this run

name: Release RC
on:
push:
branches:
- dev
jobs:
state:
if: ${{ github.actor == 'github-merge-queue[bot]' }}
name: State
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
outputs:
HAS_ASSETS: ${{ steps.scope.outputs.result }}
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"
## Высчитываем условие для загрузки assets
- name: Computed scope state
id: scope
uses: actions/github-script@v6
env:
RAW_DATA: ${{ steps.lerna_ls.outputs.RAW_DATA }}
with:
script: |
const processingScope = require('./.github/processing-scope.js');
const state = processingScope();
return state.HAS_ASSETS ?? false;
publish:
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
commit-message: "Update package-lock.json files"
upload_assets: ${{ needs.state.outputs.HAS_ASSETS == 'true' }}
auto-options: '--no-changelog'
secrets:
gh_token: ${{ secrets.GH_TOKEN }}
npm_registry_token: ${{ secrets.NPM_REGISTRY_TOKEN }}
catch:
name: Handle errors
runs-on: ubuntu-latest
needs: [ state, publish ]
if: ${{ always() && contains(needs.*.result, 'failure') }}
env:
FAILED_JOB_NAME: ${{ contains(needs.change-state.result, 'failure') && 'State' || 'Publish RC version / publish' }}
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: Create message
env:
PR: ${{ fromJSON(needs.state.outputs.PR).pr }}
USER: ${{ fromJSON(needs.state.outputs.PR).user }}
FAILURE_STEP: ${{ fromJSON(steps.job.outputs.result).name }}
JOB: ${{ fromJSON(steps.job.outputs.result).job }}
run: |
step="**Failure step**: ${{ env.FAILURE_STEP }}"
message='@${{ env.USER }}\nПосмотри пожалуйста, упала публикация твоего pull request: [${{ env.PR }}](${{ env.JOB }})'
echo "NOTIFICATION="$step\\n\\n$message"" >> $GITHUB_ENV
- name: Create the Mattermost Message
run: |
echo "{\"text\":\" ${{ env.NOTIFICATION }}\"}" > mattermost.json
- name: Send notification
uses: mattermost/action-mattermost-notify@master
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOKS_NOTIFICATIONS_MM }}