Skip to content

Commit a8f05ee

Browse files
authored
chore(.github): replace Travis CI with GH Actions (#266)
1 parent 637224b commit a8f05ee

4 files changed

Lines changed: 136 additions & 19 deletions

File tree

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
# Publish `master` as Docker `latest` image.
6+
branches:
7+
- master
8+
# Publish `v1.2.3` tags as releases.
9+
tags:
10+
- v*
11+
# Run tests for any PRs against master.
12+
pull_request:
13+
branches:
14+
- master
15+
16+
env:
17+
IMAGE_NAME: go-dev
18+
19+
jobs:
20+
# Run tests.
21+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
22+
test:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- name: Build container
29+
run: |
30+
if [ -f docker-compose.test.yml ]; then
31+
docker-compose --file docker-compose.test.yml build
32+
else
33+
make build
34+
fi
35+
36+
- name: Run tests
37+
run: |
38+
if [ -f docker-compose.test.yml ]; then
39+
docker-compose --file docker-compose.test.yml run sut
40+
else
41+
make test
42+
fi
43+
44+
# Push image to GitHub Packages, Docker Hub, and quay.io.
45+
# Microsoft Container Registry (MCR) packaging and publishing is handled by
46+
# an Azure Pipelines job.
47+
# See also https://docs.docker.com/docker-hub/builds/
48+
push:
49+
# Ensure test job passes before pushing image.
50+
needs: test
51+
52+
runs-on: ubuntu-latest
53+
if: github.event_name == 'push'
54+
55+
steps:
56+
- uses: actions/checkout@v2
57+
58+
- name: Build image
59+
run: docker build rootfs --tag $IMAGE_NAME
60+
61+
- name: Log into GitHub package registry
62+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
63+
64+
- name: Push image to GitHub package registry
65+
run: |
66+
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
67+
68+
# Change all uppercase to lowercase
69+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
70+
71+
# Strip git ref prefix from version
72+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
73+
74+
# Strip "v" prefix from tag name
75+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
76+
77+
# Use Docker `latest` tag convention
78+
[ "$VERSION" == "master" ] && VERSION=latest
79+
80+
echo IMAGE_ID=$IMAGE_ID
81+
echo VERSION=$VERSION
82+
83+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
84+
docker push $IMAGE_ID:$VERSION
85+
86+
- name: Log into Docker Hub
87+
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USER }} --password-stdin
88+
89+
- name: Push image to Docker Hub
90+
run: |
91+
GITHUB_ORG=$(echo "${{ github.repository }}" | sed -e 's#/.*##')
92+
IMAGE_ID=$GITHUB_ORG/$IMAGE_NAME
93+
94+
# Change all uppercase to lowercase
95+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
96+
97+
# Strip git ref prefix from version
98+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
99+
100+
# Strip "v" prefix from tag name
101+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
102+
103+
# Use Docker `latest` tag convention
104+
[ "$VERSION" == "master" ] && VERSION=latest
105+
106+
echo IMAGE_ID=$IMAGE_ID
107+
echo VERSION=$VERSION
108+
109+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
110+
docker push $IMAGE_ID:$VERSION
111+
112+
- name: Log into quay.io
113+
run: echo "${{ secrets.QUAYIO_PASSWORD }}" | docker login quay.io -u ${{ secrets.QUAYIO_USER }} --password-stdin
114+
115+
- name: Push image to quay.io
116+
run: |
117+
IMAGE_ID=quay.io/$GITHUB_ORG/$IMAGE_NAME
118+
119+
# Change all uppercase to lowercase
120+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
121+
122+
# Strip git ref prefix from version
123+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
124+
125+
# Strip "v" prefix from tag name
126+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
127+
128+
# Use Docker `latest` tag convention
129+
[ "$VERSION" == "master" ] && VERSION=latest
130+
131+
echo IMAGE_ID=$IMAGE_ID
132+
echo VERSION=$VERSION
133+
134+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
135+
docker push $IMAGE_ID:$VERSION

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION := $(shell git describe --tags --exact-match 2>/dev/null || echo latest)
1+
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || echo latest)
22
REGISTRY ?= quay.io/
33
IMAGE_PREFIX ?= deis
44
IMAGE := ${REGISTRY}${IMAGE_PREFIX}/go-dev:${VERSION}

_scripts/ci/deploy.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)