-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (43 loc) · 1.86 KB
/
cd.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
name: Continuous Deployment
on: [push, pull_request]
jobs:
cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Test
run: |
./run-test.sh
env:
SAXON_HOME: ${{ github.workspace }}/validator
- name: Publish as 'unstable'
if: github.ref == 'refs/heads/master'
run: |
BRANCH=${GITHUB_REF/refs\/heads\//}
TIMESTAMP=$(date --utc +%Y%m%d.%H%M)
SHORT_SHA=${GITHUB_SHA:0:8}
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker build --no-cache -t $PROJECT/$CONTAINER_NAME:unstable -t $PROJECT/$CONTAINER_NAME:${BRANCH}-${SHORT_SHA}-${TIMESTAMP} -t $PROJECT/$CONTAINER_NAME:${BRANCH}-${SHORT_SHA} -t $PROJECT/$CONTAINER_NAME:latest .
docker push $PROJECT/$CONTAINER_NAME
env:
PROJECT: elifesciences
CONTAINER_NAME: basex-validator
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish as 'stable'
if: contains(github.ref, 'refs/tags/v')
run: |
SEMVER="${GITHUB_REF/refs\/tags\/v/}"
MAJOR="$(echo "${SEMVER}" | cut -d'.' -f1)"
MINOR="$(echo "${SEMVER}" | cut -d'.' -f2)"
PATCH="$(echo "${SEMVER}" | cut -d'.' -f3)"
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker build --no-cache -t $PROJECT/$CONTAINER_NAME:stable -t $PROJECT/$CONTAINER_NAME:${MAJOR}.${MINOR}.${PATCH} -t $PROJECT/$CONTAINER_NAME:${MAJOR}.${MINOR} -t $PROJECT/$CONTAINER_NAME:${MAJOR} .
docker push $PROJECT/$CONTAINER_NAME
env:
PROJECT: elifesciences
CONTAINER_NAME: basex-validator
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}