-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (51 loc) · 1.62 KB
/
publish_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
name: "Publish Docker Images"
on:
push:
branches:
- master
paths:
- "Dockerfile.build"
- "Dockerfile.prod"
jobs:
publish-production-image:
name: "Publish production image"
runs-on: ubuntu-latest
env:
IMAGE_NAME: production
VERSION: latest
DOCKERFILE_NAME: Dockerfile.prod
steps:
- name: "Checkout source code"
uses: "actions/checkout@v2"
with:
ref: ${{ github.ref }}
- name: Login to ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build image
run: docker build . --file $DOCKERFILE_NAME --tag $IMAGE_NAME
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
publish-build-image:
name: "Publish build image"
runs-on: ubuntu-latest
env:
IMAGE_NAME: build
VERSION: latest
DOCKERFILE_NAME: Dockerfile.build
steps:
- name: "Checkout source code"
uses: "actions/checkout@v2"
with:
ref: ${{ github.ref }}
- name: Login to ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build image
run: docker build . --file $DOCKERFILE_NAME --tag $IMAGE_NAME
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION