-
Notifications
You must be signed in to change notification settings - Fork 3
160 lines (138 loc) · 4.69 KB
/
build.yml
File metadata and controls
160 lines (138 loc) · 4.69 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
env:
# Change this to upload the built image to your own organization.
docker_tag_prefix: ghcr.io/tietokilta
jobs:
build:
name: Format, Lint, Check types & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Setup turborepo cache
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version-file: package.json
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: "Build ui package"
run: pnpm turbo run build --filter=@tietokilta/ui --force
- name: Format (to ensure that code has been formatted)
run: pnpm format && git diff --exit-code
- name: Generate Payload types
run: pnpm codegen
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Build all
run: pnpm build
publish-npm:
name: Publish @tietokilta/ui to npm
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
# Publish on main branch pushes
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && github.event.action == 'published')
steps:
- name: Check out the repo
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Setup Node.js for npm (OIDC)
uses: actions/setup-node@v6
with:
node-version-file: package.json
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Update npm to latest (required for OIDC)
run: npm install -g npm@^11
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build UI package
run: pnpm --filter @tietokilta/ui build
- name: Publish @tietokilta/ui (alpha and latest)
run: |
pnpm publish --filter @tietokilta/ui --no-git-checks --access public --provenance --tag alpha --tag latest
docker-build-and-push:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && github.event.action == 'published')
needs: build
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{env.docker_tag_prefix}}/web
tags: |
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }}
type=raw,value=sha-${{github.sha}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Push to GitHub Packages
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT_SHA=${{github.sha}}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
# only run on published releases, enable this when we release
#if: github.event_name == 'release' && github.event.action == 'published'
name: Deploy to Azure
runs-on: ubuntu-latest
needs: docker-build-and-push
steps:
- name: Login via Azure CLI
uses: azure/login@v2
with:
client-id: ${{secrets.AZURE_CLIENT_ID}}
subscription-id: ${{secrets.AZURE_SUBSCRIPTION_ID}}
tenant-id: ${{secrets.AZURE_TENANT_ID}}
- uses: azure/webapps-deploy@v3
with:
app-name: tikweb-web-prod # TODO: if we ever setup more envs than prod, make this variable customizable
images: "${{ env.docker_tag_prefix }}/web:sha-${{ github.sha }}"