generated from nlpsandbox/date-annotator-example-java
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (101 loc) · 3.12 KB
/
ci.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
name: CI
on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
push:
branches:
- main
tags:
- '*.*.*'
pull_request:
env:
docker_repository: docker.synapse.org/syn22277123/phi-annotator-example-java
jobs:
configure:
runs-on: ubuntu-latest
steps:
- name: Create configuration
run: |
DOCKER_IMAGE=${{ env.docker_repository }}
VERSION=noop
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
PUSH=true
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
PUSH=true
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
PUSH=true
fi
printf "%s\n" \
"version=${VERSION}" \
"tags=${TAGS}" \
"created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
"push=${PUSH}" | tee -a .github_env
- name: Upload .github_env
uses: actions/upload-artifact@v2
with:
name: GITHUB_ENV
path: .github_env
lint:
needs: [configure]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint Dockerfiles
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: server/Dockerfile
- name: Validate docker-compose.yml
run: |
docker-compose -f docker-compose.yml config >/dev/null
docker:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download .github_env
uses: actions/download-artifact@v2
with:
name: GITHUB_ENV
path: .
- name: Restore $GITHUB_ENV
run: cat .github_env >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Synapse Docker Registry
if: env.push == 'true'
uses: docker/login-action@v1
with:
registry: docker.synapse.org
username: ${{ secrets.SYNAPSE_USERNAME }}
password: ${{ secrets.SYNAPSE_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: server
file: server/Dockerfile
platforms: linux/amd64
push: ${{ env.push }}
tags: ${{ env.tags }}
labels: |
org.opencontainers.image.created=${{ env.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ env.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}