forked from requarks/wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (97 loc) · 3.19 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
name: docker-build
on:
push:
branches:
- tyclipso
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
REGISTRY: ghcr.io
jobs:
# Test building the docker image on pull requests
test-build:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build image
uses: docker/build-push-action@v2
with:
push: false
context: .
file: dev/build/Dockerfile
# Build image and push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
build-and-push-image:
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=tag,priority=400
type=sha,prefix=,priority=200
type=edge,priority=100
- name: Get build time
uses: gerred/actions/current-time@master
id: build_time
- name: Rewrite entries in package.json to match repository
uses: microsoft/variable-substitution@v1
with:
files: "package.json"
env:
version: ${{ steps.meta.outputs.version }}
releaseDate: ${{ steps.build_time.outputs.time }}
repository.url: "git+${{ github.server_url }}/${{ github.repository }}.git"
bugs.url: "${{ github.server_url }}/${{ github.repository }}/issues"
homepage: "${{ github.server_url }}/${{ github.repository }}#readme"
- name: Build and push Docker image on branch
if: false == startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
push: true
context: .
file: dev/build/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract metadata for Docker for tag
id: metatag
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=tag
- name: Set dev flag to false in package.json for tag
if: startsWith(github.ref, 'refs/tags/v')
uses: microsoft/variable-substitution@v1
with:
files: "package.json"
env:
dev: "false"
- name: Build and push Docker image for tag
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
push: true
context: .
file: dev/build/Dockerfile
tags: ${{ steps.metatag.outputs.tags }}
labels: ${{ steps.metatag.outputs.labels }}