-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (91 loc) · 3.3 KB
/
Copy pathdocker-build.yaml
File metadata and controls
102 lines (91 loc) · 3.3 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
name: Docker Build
on:
pull_request:
branches:
- main
paths:
- app/**
- assets/**
- content/**
- public/**
- server/**
- Dockerfile
- nuxt.config.ts
- nuxt.schema.ts
- package.json
- pnpm-lock.yaml
- tailwind.config.ts
- tsconfig.json
push:
branches:
- main
paths:
- app/**
- assets/**
- content/**
- public/**
- server/**
- Dockerfile
- nuxt.config.ts
- nuxt.schema.ts
- package.json
- pnpm-lock.yaml
- tailwind.config.ts
- tsconfig.json
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: qemu setup
uses: docker/setup-qemu-action@v3
- name: buildx setup
uses: docker/setup-buildx-action@v3
- name: set image tag
if: ${{ github.event_name != 'pull_request' }}
run: echo "IMAGE_TAG=${GITHUB_REF_NAME}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: set image tag (pr)
if: ${{ github.event_name == 'pull_request' }}
run: echo "IMAGE_TAG=pr${{ github.event.number }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: set environment
run: |
echo "REPOSITORY=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
echo "IMAGE=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
echo "LABEL_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "LABEL_REVISION=${GITHUB_SHA}" >> $GITHUB_ENV
echo "BUILD_DATETIME=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
- name: docker login
uses: docker/login-action@v3
with:
registry: ${{ secrets.STJUDECLOUD_REGISTRY_URL }}
username: ${{ secrets.STJUDECLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.STJUDECLOUD_REGISTRY_PASSWORD }}
- name: docker build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
tags: ${{ secrets.STJUDECLOUD_REGISTRY_URL }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
push: true
build-args: |
NUXT_UI_PRO_LICENSE=${{ secrets.NUXT_UI_PRO_LICENSE }}
labels: |
org.opencontainers.image.title=${{ env.REPOSITORY }}
org.opencontainers.image.url=${{ env.LABEL_URL }}
org.opencontainers.image.source=${{ env.LABEL_URL }}
org.opencontainers.image.version=${{ env.IMAGE_TAG }}
org.opencontainers.image.revision=${{ env.LABEL_REVISION }}
org.opencontainers.image.created=${{ env.BUILD_DATETIME }}
- name: tag latest
if: ${{ github.event_name != 'pull_request' }}
run: |
docker pull ${{ secrets.STJUDECLOUD_REGISTRY_URL }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
docker tag ${{ secrets.STJUDECLOUD_REGISTRY_URL }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ secrets.STJUDECLOUD_REGISTRY_URL }}/${{ env.REPOSITORY }}:latest
docker push ${{ secrets.STJUDECLOUD_REGISTRY_URL }}/${{ env.REPOSITORY }}:latest