-
-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (112 loc) · 4.14 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# ----------------------------------------------------------------------------------------------------------------------
# Build and Deploy docker images
#
# This action requires the following secrets to be set:
# * RANCHER_ACCESS_KEY - API Access key created in Rancher.
# * RANCHER_SECRET_KEY - API Secret key created in Rancher.
# ----------------------------------------------------------------------------------------------------------------------
name: Docker
on:
push:
branches:
- master
tags:
- v*
release:
types: [published, prereleased, released]
env:
IMAGE_NAME: rpgkeeper
jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Login to docker hub
if: success()
uses: actions-hub/docker/login@master
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Set ENV Variables.
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo VERSION=$VERSION >> $GITHUB_ENV
- name: Build docker
if: success()
run: |
if [ "$VERSION" == "latest" ]
then
docker build -t morgul/rpgkeeper:latest .
else
docker build -t morgul/rpgkeeper:${VERSION} -t morgul/rpgkeeper:latest .
fi
- name: Push docker
if: success()
run: |
if [ "$VERSION" == "latest" ]
then
docker push morgul/rpgkeeper:latest
else
docker push morgul/rpgkeeper:${VERSION} -t morgul/rpgkeeper:latest
fi
# uses: actions-hub/docker@master
# with:
# args: push morgul/rpgkeeper:${VERSION}
# Deploys Beta docker
deploy-beta:
needs: push
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Set ENV Variables.
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo VERSION=$VERSION >> $GITHUB_ENV
- name: Deploy Beta Site
uses: SkewedAspect/[email protected]
env:
RANCHER_BEARER_TOKEN: ${{ secrets.RANCHER_API_KEY }}
RANCHER_CLUSTER_ID: 'c-g65ld'
RANCHER_NAMESPACE: 'rpgkeeper'
RANCHER_PROJECT_ID: 'p-7wdzf'
RANCHER_URL: 'https://rancher.skewedaspect.com/'
RANCHER_WORKLOAD: 'rpgkeeper-beta'
IMAGE_TAG: ${{ env.VERSION }}
# Deploys prod docker
deploy-prod:
needs: push
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
- name: Set ENV Variables.
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo VERSION=$VERSION >> $GITHUB_ENV
- name: Deploy Production Site
uses: SkewedAspect/[email protected]
env:
RANCHER_BEARER_TOKEN: ${{ secrets.RANCHER_API_KEY }}
RANCHER_CLUSTER_ID: 'c-g65ld'
RANCHER_NAMESPACE: 'rpgkeeper'
RANCHER_PROJECT_ID: 'p-7wdzf'
RANCHER_URL: 'https://rancher.skewedaspect.com/'
RANCHER_WORKLOAD: 'rpgkeeper'
IMAGE_TAG: ${{ env.VERSION }}