-
Notifications
You must be signed in to change notification settings - Fork 24
135 lines (117 loc) · 4.14 KB
/
Copy pathci-cd.yaml
File metadata and controls
135 lines (117 loc) · 4.14 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
name: validate
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
validate:
name: Validate on Node ${{ matrix.node }} / ${{ matrix.os }} / ${{ matrix.storage-engine }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
strategy:
matrix:
node: ["22.x", "24.x"]
os: [ubuntu-latest, windows-latest, macOS-latest]
storage-engine: [in-memory, sqlite]
runs-on: ${{ matrix.os }}
env:
CI: true
STORAGE_ENGINE: ${{ matrix.storage-engine }}
steps:
- name: Checkout repo
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Node.js
uses: labd/gh-actions-typescript/pnpm-install@e7a21fb56b52bf2d91616e34f0bc3f4f9a821b62 # main
with:
node-version: ${{ matrix.node }}
- name: Check formatting and typing
run: pnpm check
- name: Run tests
run: pnpm test:ci
- name: Run build
run: pnpm build
release:
timeout-minutes: 15
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.pull_request.draft == false
permissions:
id-token: write
contents: write
pull-requests: write
environment: release
outputs:
published: ${{ steps.changesets.outputs.published }}
needs: validate
steps:
- name: Checkout repo
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Node.js
uses: labd/gh-actions-typescript/pnpm-install@e7a21fb56b52bf2d91616e34f0bc3f4f9a821b62 # main
- name: Run build
run: pnpm build
- name: Upgrade npm for trusted publishing
run: npm i -g npm@^11.6.4
- name: Create and publish versions
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
id: changesets
with:
title: "Release new version"
commit: "update version"
publish: pnpm publish:ci
version: pnpm publish:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
docker:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.published == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Resolve newest release tag
id: latest_tag
shell: bash
run: |
TAG="$(git tag --points-at HEAD --sort=-v:refname | head -n 1)"
if [ -z "$TAG" ]; then
TAG="$(git tag --sort=-creatordate | head -n 1)"
fi
if [ -z "$TAG" ]; then
echo "No git tags found after release" >&2
exit 1
fi
echo "value=$TAG" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to DockerHub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: labdigital/commercetools-mock-server
tags: |
type=semver,pattern={{version}},value=${{ steps.latest_tag.outputs.value }}
type=raw,value=latest,enable=${{ !contains(steps.latest_tag.outputs.value, 'beta') }}
- name: Build and push
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}