forked from CorentinTh/it-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 1.79 KB
/
gitmotion-docker-image.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
name: Build and Push Docker Image
on:
push:
branches:
- gitmotion/main # You can also specify the branch where you want the action to trigger, like `develop`, or your custom branch.
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm i
- name: Run linters
run: pnpm lint
- name: Run unit tests
run: pnpm test
- name: Build the app
run: pnpm build
build:
runs-on: ubuntu-latest
needs:
- ci
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
# Set up Docker Buildx (to support multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to GitHub Container Registry (GHCR)
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
# Build and push the Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ secrets.GHCR_USERNAME }}/it-tools:latest
# Optionally add version tags or specific branch tags like:
# tags: |
# ghcr.io/${{ secrets.GHCR_USERNAME }}/your-repo-name:latest
# ghcr.io/${{ secrets.GHCR_USERNAME }}/your-repo-name:${{ github.sha }}
# Optionally log out
- name: Log out from GitHub Container Registry
run: docker logout ghcr.io