forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
131 lines (114 loc) 路 3.71 KB
/
action.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
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
name: Build API Docker Image
description: 'Builds a docker image for the API'
inputs:
tag:
description: 'The tag to use for the image'
required: false
push:
description: 'Push the image to the registry'
required: false
default: 'false'
github_token:
description: 'The token to use for logging into ghcr.io'
required: true
fork:
description: 'Whether this is being triggered from a forked repo'
required: false
default: 'false'
docker_name:
description: 'Name for docker image'
required: true
bullmq_secret:
description: 'Bullmq secret api token'
required: true
outputs:
image:
description: 'The image that was built'
value: ${{ steps.build-image.outputs.IMAGE }}
runs:
using: composite
steps:
- name: 鉀忥笍 build api
shell: bash
run: pnpm build:api
- uses: crazy-max/ghaction-setup-docker@v2
with:
version: v24.0.6
daemon-config: |
{
"features": {
"containerd-snapshotter": true
}
}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: 'image=moby/buildkit:v0.12.4'
- name: Login To Registry
shell: bash
env:
GH_ACTOR: ${{ github.actor }}
GH_PASSWORD: ${{ inputs.github_token }}
run: |
echo $GH_PASSWORD | docker login ghcr.io -u $GH_ACTOR --password-stdin
- name: Set Bull MQ Env variable for EE
shell: bash
run: |
echo "BULL_MQ_PRO_NPM_TOKEN=${{ inputs.bullmq_secret }}" >> $GITHUB_ENV
if: contains( inputs.docker_name , 'ee')
- name: Build with Buildx, tag, and test
shell: bash
env:
REGISTRY_OWNER: novuhq
DOCKER_NAME: ${{ inputs.docker_name }}
IMAGE_TAG: ${{ github.sha }}
GH_ACTOR: ${{ github.actor }}
GH_PASSWORD: ${{ inputs.github_token }}
run: |
set -x
cd apps/api && pnpm run docker:build
- name: Tag and test
id: build-image
shell: bash
env:
REGISTRY_OWNER: novuhq
DOCKER_NAME: ${{ inputs.docker_name }}
IMAGE_TAG: ${{ github.sha }}
GH_ACTOR: ${{ github.actor }}
GH_PASSWORD: ${{ inputs.github_token }}
run: |
echo "Built image"
docker tag novu-api ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG
docker run --network=host --name api -dit --env NODE_ENV=test ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG
docker run --network=host appropriate/curl --retry 10 --retry-delay 5 --retry-connrefused http://127.0.0.1:1337/v1/health-check | grep 'ok'
echo "IMAGE=ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Optionally tag docker image
if: ${{ inputs.tag }}
shell: bash
env:
REGISTRY_OWNER: novuhq
DOCKER_NAME: ${{ inputs.docker_name }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker tag ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:${{ inputs.tag }}
- name: Push PR tag image
if: ${{ inputs.push == 'true' }}
shell: bash
env:
REGISTRY_OWNER: novuhq
DOCKER_NAME: ${{ inputs.docker_name }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker push ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:$IMAGE_TAG
- name: Push custom tag image
if: ${{ inputs.push == 'true' && inputs.tag }}
shell: bash
env:
REGISTRY_OWNER: novuhq
DOCKER_NAME: ${{ inputs.docker_name }}
run: |
docker push ghcr.io/$REGISTRY_OWNER/$DOCKER_NAME:${{ inputs.tag }}