-
Notifications
You must be signed in to change notification settings - Fork 6
55 lines (45 loc) · 1.79 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
name: CI
on: [push, pull_request, workflow_dispatch]
jobs:
run:
runs-on: ubuntu-latest
env:
REGISTRY_PORT: 5000
steps:
- uses: actions/checkout@v2
- name: Set $CACHE_DATE
run: echo "CACHE_DATE=$(date --utc +%Y%m%dT%H%M%SZ)" | tee -a $GITHUB_ENV
- if: github.event_name != 'pull_request' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch
name: Set $TAG (default branch)
run: echo "TAG=build-$CACHE_DATE" | tee -a $GITHUB_ENV
- if: env.TAG == ''
name: Set $TAG (PRs, non-default branch)
# From `man docker-image-tag`: The tag name must be valid ASCII and may
# contain lowercase and uppercase letters, digits, underscores, periods
# and hyphens.
run: echo "TAG=branch-${GITHUB_REF_NAME//[^A-Za-z0-9._-]/-}" | tee -a $GITHUB_ENV
- run: ./devel/start-localhost-registry $REGISTRY_PORT
- run: ./devel/build -r localhost:$REGISTRY_PORT -t $TAG
- if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- if: github.event_name != 'pull_request' && startsWith(env.TAG, 'branch-')
name: Push $TAG (non-default branch)
run: ./devel/push $TAG
- uses: actions/setup-python@v4
with:
python-version: ~3
- name: Run zika-tutorial
run: |
git clone https://github.com/nextstrain/zika-tutorial
pip install nextstrain-cli
nextstrain build --image nextstrain/base:$TAG zika-tutorial -F
- if: startsWith(env.TAG, 'build-')
name: Push $TAG + latest (default branch)
run: |
./devel/tag-latest $TAG
./devel/push latest $TAG
- if: always()
run: ./devel/stop-localhost-registry