-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (40 loc) · 1.45 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
name: Docker
on:
push:
branches: [ master ]
tags: [ '*' ]
workflow_dispatch:
jobs:
push:
if: github.repository == 'rq/rq'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Push
run: |
# Parse Version
# "master" -> "master"
# "v1.2.3" -> "1.2.3", "1.2", "1", "latest"
VERSIONS=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && {
VERSIONS=$(echo $VERSIONS | sed -e 's/^v//')
i="$VERSIONS"
while [[ "$i" == *"."* ]]
do i="$(echo "$i" | sed 's/\(.*\)\..*/\1/g')"
VERSIONS="$VERSIONS $i"
done
VERSIONS="$VERSIONS latest"
}
echo Building with tags: $VERSIONS
# Login to registries
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u selwin --password-stdin
# Build image
docker build . --tag worker
# Tag and Push
for VERSION in $VERSIONS
do docker tag worker redisqueue/worker:$VERSION
docker push redisqueue/worker:$VERSION
docker tag worker docker.pkg.github.com/rq/rq/worker:$VERSION
docker push docker.pkg.github.com/rq/rq/worker:$VERSION
done