Skip to content

Commit 3ac537e

Browse files
committed
ci: New CI/CD process
1 parent 3bbda39 commit 3ac537e

File tree

7 files changed

+86
-73
lines changed

7 files changed

+86
-73
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,23 @@ jobs:
3030
- name: Setup Node.js
3131
uses: ./.github/actions
3232

33-
- name: Determine base branch for NX affected
34-
id: set-base
33+
- name: Determine base for NX affected (if not master)
34+
if: ${{ inputs.mainBranch != 'master' }}
3535
shell: bash
3636
run: |
37-
if [ "${{ github.event.inputs.mainBranch }}" = "master" ]; then
38-
echo "base=master" >> $GITHUB_OUTPUT
39-
echo "Using base branch 'master'"
40-
else
41-
LAST_TAG=$(git describe --tags --abbrev=0)
42-
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
43-
echo "base=$LAST_TAG_HASH" >> $GITHUB_OUTPUT
44-
echo "Using last tag hash: $LAST_TAG_HASH"
45-
fi
37+
LAST_TAG=$(git describe --tags --abbrev=0)
38+
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
39+
CURRENT_COMMIT=$(git rev-parse HEAD)
40+
echo "Using last tag hash as NX_BASE: $LAST_TAG_HASH"
41+
echo "Using current commit as NX_HEAD: $CURRENT_COMMIT"
42+
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
43+
echo "NX_HEAD=$CURRENT_COMMIT" >> $GITHUB_ENV
4644
47-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
45+
- name: Determine base for NX affected (if master)
46+
if: ${{ inputs.mainBranch == 'master' }}
4847
uses: nrwl/nx-set-shas@v4
4948
with:
50-
main-branch-name: ${{ steps.set-base.outputs.base }}
49+
main-branch-name: ${{ inputs.mainBranch }}
5150

5251
- name: Build Libraries
5352
run: npx nx affected --target=build --parallel=3 --exclude='*,!tag:type:publish'

.github/workflows/bump-version.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ on:
2222
required: false
2323
type: boolean
2424
default: false
25+
secrets:
26+
NODE_AUTH_TOKEN:
27+
required: true
28+
GITHUB_TOKEN_SECRET:
29+
required: true
30+
PAT:
31+
required: true
32+
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_SECRET }}
36+
NPM_CONFIG_PROVENANCE: true
37+
2538
jobs:
2639
bump-version:
2740
runs-on: ubuntu-latest
@@ -37,9 +50,5 @@ jobs:
3750
run: |
3851
git config --global user.email "[email protected]"
3952
git config --global user.name "GitHub Actions"
40-
npx nx release --skip-publish --first-release=${{ github.event.inputs.first-release }} --projects=${{ github.event.inputs.projects }} --dry-run=${{ github.event.inputs.dry-run }}
53+
npx nx release --skip-publish --first-release=${{ inputs.first-release }} --projects=${{ inputs.projects }} --dry-run=${{ inputs.dry-run }}
4154
shell: bash
42-
env:
43-
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
44-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
NPM_CONFIG_PROVENANCE: true

.github/workflows/compute-projects.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,21 @@ jobs:
4747

4848
- name: Get projects by tag
4949
id: tag_projects
50-
if: ${{ github.event.inputs.tagChoice != '' }}
50+
if: ${{ inputs.tagChoice != '' }}
5151
shell: bash
5252
run: |
53-
echo "Using tag: ${{ github.event.inputs.tagChoice }}"
54-
projects=$(npx nx show projects --exclude="*,!${{ github.event.inputs.tagChoice }}" --sep=',')
53+
echo "Using tag: ${{ inputs.tagChoice }}"
54+
projects=$(npx nx show projects --exclude="*,!${{ inputs.tagChoice }}" --sep=',')
5555
echo "projects=$projects" >> $GITHUB_OUTPUT
5656
echo "Projects by tag: $projects"
5757
58-
# Если тег не выбран, собираем выбранные проекты через чекбоксы
59-
- name: Collect projects from checkboxes
60-
id: checkbox_projects
61-
if: ${{ github.event.inputs.tagChoice == '' }}
58+
- name: Collect projects from select
59+
id: select_projects
60+
if: ${{ inputs.tagChoice == '' }}
6261
shell: bash
6362
run: |
6463
final=""
65-
for var in "${{ github.event.inputs.projectList1 }}" "${{ github.event.inputs.projectList2 }}" "${{ github.event.inputs.projectList3 }}"; do
64+
for var in "${{ inputs.projectList1 }}" "${{ inputs.projectList2 }}" "${{ inputs.projectList3 }}"; do
6665
if [ ! -z "$var" ]; then
6766
if [ -z "$final" ]; then
6867
final="$var"
@@ -83,10 +82,10 @@ jobs:
8382
id: final
8483
shell: bash
8584
run: |
86-
if [ -n "${{ github.event.inputs.tagChoice }}" ]; then
85+
if [ -n "${{ inputs.tagChoice }}" ]; then
8786
final="${{ steps.tag_projects.outputs.projects }}"
8887
else
89-
final="${{ steps.checkbox_projects.outputs.selectProjects }}"
88+
final="${{ steps.select_projects.outputs.selectProjects }}"
9089
fi
9190
final=$(echo "$final" | xargs)
9291
echo "finalProjects=$final" >> $GITHUB_OUTPUT

.github/workflows/create-release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ jobs:
105105
mainBranch: "last-tag"
106106
secrets:
107107
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
108+
GIST_SECRET: ${{ secrets.GIST_SECRET }}
109+
GIST_ID: ${{ secrets.GIST_ID }}
108110

109111
bump-version:
110112
needs: [build]
@@ -114,3 +116,7 @@ jobs:
114116
first-release: ${{ needs.compute-projects.outputs.first-release }}
115117
beta-release: ${{ needs.compute-projects.outputs.beta-release }}
116118
dry-run: ${{ needs.compute-projects.outputs.dry-run }}
119+
secrets:
120+
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
121+
GITHUB_TOKEN_SECRET: ${{ secrets.GITHUB_TOKEN }}
122+
PAT: ${{secrets.PAT}}

.github/workflows/e2e-test.yaml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,25 @@ jobs:
3838
uses: actions/checkout@v4
3939
- name: Setup Node.js
4040
uses: ./.github/actions
41-
- name: Determine base branch for NX affected
42-
id: set-base
41+
42+
- name: Determine base for NX affected (if not master)
43+
if: ${{ inputs.mainBranch != 'master' }}
4344
shell: bash
4445
run: |
45-
if [ "${{ github.event.inputs.mainBranch }}" = "master" ]; then
46-
echo "base=master" >> $GITHUB_OUTPUT
47-
echo "Using base branch 'master'"
48-
else
49-
LAST_TAG=$(git describe --tags --abbrev=0)
50-
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
51-
echo "base=$LAST_TAG_HASH" >> $GITHUB_OUTPUT
52-
echo "Using last tag hash: $LAST_TAG_HASH"
53-
fi
54-
55-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
46+
LAST_TAG=$(git describe --tags --abbrev=0)
47+
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
48+
CURRENT_COMMIT=$(git rev-parse HEAD)
49+
echo "Using last tag hash as NX_BASE: $LAST_TAG_HASH"
50+
echo "Using current commit as NX_HEAD: $CURRENT_COMMIT"
51+
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
52+
echo "NX_HEAD=$CURRENT_COMMIT" >> $GITHUB_ENV
53+
54+
- name: Determine base for NX affected (if master)
55+
if: ${{ inputs.mainBranch == 'master' }}
5656
uses: nrwl/nx-set-shas@v4
5757
with:
58-
main-branch-name: ${{ steps.set-base.outputs.base }}
58+
main-branch-name: ${{ inputs.mainBranch }}
59+
5960
- run: npm run typeorm migration:run
6061
- run: npm run seed:run
6162
- run: npx nx run json-api-server-e2e:e2e --parallel=1

.github/workflows/test.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ jobs:
2626
- name: Setup Node.js
2727
uses: ./.github/actions
2828

29-
- name: Determine base branch for NX affected
30-
id: set-base
29+
- name: Determine base for NX affected (if not master)
30+
if: ${{ inputs.mainBranch != 'master' }}
3131
shell: bash
3232
run: |
33-
if [ "${{ github.event.inputs.mainBranch }}" = "master" ]; then
34-
echo "base=master" >> $GITHUB_OUTPUT
35-
echo "Using base branch 'master'"
36-
else
37-
LAST_TAG=$(git describe --tags --abbrev=0)
38-
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
39-
echo "base=$LAST_TAG_HASH" >> $GITHUB_OUTPUT
40-
echo "Using last tag hash: $LAST_TAG_HASH"
41-
fi
33+
LAST_TAG=$(git describe --tags --abbrev=0)
34+
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
35+
CURRENT_COMMIT=$(git rev-parse HEAD)
36+
echo "Using last tag hash as NX_BASE: $LAST_TAG_HASH"
37+
echo "Using current commit as NX_HEAD: $CURRENT_COMMIT"
38+
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
39+
echo "NX_HEAD=$CURRENT_COMMIT" >> $GITHUB_ENV
4240
43-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
41+
- name: Determine base for NX affected (if master)
42+
if: ${{ inputs.mainBranch == 'master' }}
4443
uses: nrwl/nx-set-shas@v4
4544
with:
46-
main-branch-name: ${{ steps.set-base.outputs.base }}
45+
main-branch-name: ${{ inputs.mainBranch }}
4746

4847
- name: Test
4948
run: npx nx affected --target=test --parallel=3 --passWithNoTests --exclude='*,!tag:type:publish'

.github/workflows/upload-badge.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ on:
1010
secrets:
1111
NX_CLOUD_ACCESS_TOKEN:
1212
required: true
13+
GIST_SECRET:
14+
required: true
15+
GIST_ID:
16+
required: true
1317
env:
1418
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
19+
GIST_SECRET: ${{ secrets.GIST_SECRET }}
20+
GIST_ID: ${{ secrets.GIST_ID }}
1521

1622
jobs:
1723
test:
@@ -25,29 +31,23 @@ jobs:
2531
- name: Setup Node.js
2632
uses: ./.github/actions
2733

28-
- name: Determine base branch for NX affected
29-
id: set-base
34+
- name: Determine base for NX affected (if not master)
35+
if: ${{ inputs.mainBranch != 'master' }}
3036
shell: bash
3137
run: |
32-
if [ "${{ github.event.inputs.mainBranch }}" = "master" ]; then
33-
echo "base=master" >> $GITHUB_OUTPUT
34-
echo "Using base branch 'master'"
35-
else
36-
LAST_TAG=$(git describe --tags --abbrev=0)
37-
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
38-
echo "base=$LAST_TAG_HASH" >> $GITHUB_OUTPUT
39-
echo "Using last tag hash: $LAST_TAG_HASH"
40-
fi
38+
LAST_TAG=$(git describe --tags --abbrev=0)
39+
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
40+
CURRENT_COMMIT=$(git rev-parse HEAD)
41+
echo "Using last tag hash as NX_BASE: $LAST_TAG_HASH"
42+
echo "Using current commit as NX_HEAD: $CURRENT_COMMIT"
43+
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
44+
echo "NX_HEAD=$CURRENT_COMMIT" >> $GITHUB_ENV
4145
42-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
46+
- name: Determine base for NX affected (if master)
47+
if: ${{ inputs.mainBranch == 'master' }}
4348
uses: nrwl/nx-set-shas@v4
4449
with:
45-
main-branch-name: ${{ steps.set-base.outputs.base }}
46-
47-
- name: Set GIST_SECRET to env
48-
run: |
49-
echo "GIST_SECRET=${{ secrets.GIST_SECRET }}" >> $GITHUB_ENV
50-
echo "GIST_ID=${{ secrets.GIST_ID }}" >> $GITHUB_ENV
50+
main-branch-name: ${{ inputs.mainBranch }}
5151

5252
- name: Upload test coverage badge
5353
run: npx nx affected --target=upload-badge --passWithNoTests --exclude='*,!tag:type:publish'

0 commit comments

Comments
 (0)