-
Notifications
You must be signed in to change notification settings - Fork 7
116 lines (101 loc) · 3.27 KB
/
docker.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
# automatically publishes v tags to dockerhub.
# so for instance v0.5.1 wil publish but randtom wont
name: Build and Publish Version Tags
on:
push:
branches:
- '**'
tags:
- "v*"
env:
FRONTED_PORT: 4444
FRONTEND_MINIFY_JS: ON
COOKIE_SECURE_OFF: yes
API: "http://localhost:8111"
IMAGE_API_URL: "http://localhost:3333"
IMAGE_API_ACCESS_TOKEN: xxxx
SITE_API_KEY: xxxx
DEFAULT_DB: default
DEFAULT_HOST: "localhost:4444"
APP_URL: "http://localhost:4444"
APOS_BUNDLE: assets
APOS_MINIFY: 1
APOS_WORKFLOW: ON
MONGO_DB_CONNECTION_STRING: "mongodb://root:example@localhost:27017"
APOS_MONGODB_URI: "mongodb://root:example@localhost:27017"
NODE_ENV: production
IMAGE: ${{ secrets.DOCKER_IMAGE || 'openstad/frontend' }}
jobs:
build:
name: Build Docker image and push to repositories
# The type of runner that the job will run on
runs-on: ubuntu-latest
services:
mongo:
image: mongo:5
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: ${DEFAULT_DB}
ports:
- 27017:27017
options: >-
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE }}
tags: |
# branch event
type=ref,event=branch,suffix=-{{sha}}
# tag event
type=ref,event=tag
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 16
- run: npm install --production
# We currently have no frontend tests
#- run: npm run test -- --coverage
- run: mkdir assets
- name: Bundle assets
run: node apostrophe.js apostrophe:generation --create-bundle assets
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Comment build info in commit
uses: actions/github-script@0.9.0
env:
STDOUT: "Published new image: `${{ fromJson(steps.docker_build.outputs.metadata)['image.name'] }}`"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: process.env.STDOUT
})
- name: Image digest
run: echo "${{ steps.docker_build.outputs.metadata }}"