-
-
Notifications
You must be signed in to change notification settings - Fork 22
126 lines (107 loc) · 4.4 KB
/
publish-v2.1.x.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# .github/workflows/publish.yml
name: Publish to v2.1.x-deployment
on:
workflow_run:
workflows: ["CI"] # runs after CI workflow
branches: ["v2.1.x"]
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
name: Build and Push
steps:
- if: github.event.workflow_run.conclusion != 'success'
run: |
echo "CI step didn't pass, exiting"
exit 1
- name: Set variables
id: variables
shell: bash
run: |
echo "target-branch=v2.1.x-deployment" >> "$GITHUB_OUTPUT"
echo "src-branch=v2.1.x" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v3
with:
ref: ${{ steps.variables.outputs.src-branch }}
- name: Unshallow repository
run: git fetch --unshallow origin ${{ steps.variables.outputs.src-branch }}
- name: Get last successful commit
id: last-successful-commit
uses: tylermilner/last-successful-commit-hash-action@v1
with:
workflow-id: 99826346
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: development # This has to be the main branch of repository since all workflows are run from there
- name: Get commit count
id: commit-count
shell: bash
run: |
echo "Deploying $(git rev-list --count ${{ steps.last-successful-commit.outputs.commit-hash }}..${{ github.sha }})) commits!"
echo "commit-count=$(git rev-list --count ${{ steps.last-successful-commit.outputs.commit-hash }}..${{ github.sha }})" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 9.1
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "store_path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.store_path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: actions/cache/restore@v4
name: Setup Next.js cache
id: cache-nextjs-restore
with:
path: |
${{ github.workspace }}/src/build/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('src/**/*.js', 'src/**/*.jsx', 'src/**/*.ts', 'src/**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-
- name: Install all dependencies
working-directory: ./src
run: pnpm install --frozen-lockfile
- name: Build
working-directory: ./src
run: pnpm build
- name: Build cli
working-directory: ./src
run: pnpm build:cli
- uses: actions/cache/save@v4
name: Setup Next.js cache
id: cache-nextjs-save
with:
path: |
${{ github.workspace }}/src/build/cache
key: ${{ steps.cache-nextjs-restore.outputs.cache-primary-key }}
- name: Delete files not needed in deployment
working-directory: ./src
run: rm -rf __tests__ app pages components coverage data helpers hooks moonraker env recoil server utils zods test-setup.ts vitest.config.mts tsconfig.vitest.json copy-files-from-to.json components.json postcss.config.js prettier.config.mjs tailwind.config.ts
- name: Rename src/ to app/
working-directory: ./
run: mv src app
- name: Publish to ${{ steps.variables.outputs.target-branch }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: .
commit-message: |
Deployed ${{ steps.commit-count.outputs.commit-count }} commit${{ steps.commit-count.outputs.commit-count > 1 && 's' || '' }}.
https://github.com/Rat-OS/RatOS-configurator/compare/${{ steps.last-successful-commit.outputs.commit-hash }}...${{ github.sha }}
git-config-name: Mikkel Schmidt
git-config-email: mikkel.schmidt@gmail.com
branch: ${{ steps.variables.outputs.target-branch }} # The branch name where you want to push the assets