-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (68 loc) · 2.87 KB
/
pipeline.yaml
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
name: Pipeline
on:
pull_request:
push:
branches: ["*"]
jobs:
check:
name: Check formatting with Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
env:
HUSKY: 0
- run: bun install --frozen-lockfile
- uses: creyD/[email protected]
with:
prettier_options: --check .
dry: true
only_changed: true
publish:
name: Publish to Docker Hub
needs: check
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && endsWith(github.repository, '-boilerplate')
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Extract project metadata
env:
AUTHOR: ${{ vars.DOCKER_HUB_USERNAME }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }}
run: |
SEMVER=$(jq ".version" package.json | tr -d '"')
declare -a versions=()
declare -a split_by_slash=()
IFS='.' read -ra versions <<< "$SEMVER"
IFS="/" read -ra split_by_slash <<< "$GITHUB_REPOSITORY"
echo "SEMVER=$SEMVER" >> "$GITHUB_ENV"
echo "MAJOR=${versions[0]}" >> "$GITHUB_ENV"
echo "MINOR=${versions[1]}" >> "$GITHUB_ENV"
echo "AUTHOR=${AUTHOR:-split_by_slash[0]}" >> "$GITHUB_ENV"
echo "DEVELOPMENT=$GITHUB_REPOSITORY:development" >> "$GITHUB_ENV"
echo "PRODUCTION=$GITHUB_REPOSITORY:production" >> "$GITHUB_ENV"
- uses: docker/setup-buildx-action@v3
name: Setup Docker Buildx
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.AUTHOR }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Publish development tags
uses: docker/build-push-action@v6
with:
context: .devcontainer/
push: true
tags: ${{ env.DEVELOPMENT }},${{ env.DEVELOPMENT }}-${{ env.MAJOR }},${{ env.DEVELOPMENT }}-${{ env.MAJOR }}.${{ env.MINOR }},${{ env.DEVELOPMENT }}-${{ env.SEMVER }}
- name: Publish production tags
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.PRODUCTION }},${{ env.PRODUCTION }}-${{ env.MAJOR }},${{ env.PRODUCTION }}-${{ env.MAJOR }}.${{ env.MINOR }},${{ env.PRODUCTION }}-${{ env.SEMVER }}