-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (56 loc) · 1.72 KB
/
test-build-push.fe.yaml
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
name: Test && Build && Push
on:
pull_request:
branches: [main]
paths:
- scilog/**
- .github/workflows/test-build-push.fe.yaml
push:
branches: [main]
paths:
- scilog/**
- .github/workflows/test-build-push.fe.yaml
release:
types: [published]
paths:
- scilog/**
- .github/workflows/test-build-push.fe.yaml
env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/fe
CONTEXT: scilog
jobs:
test:
name: Test and build image on PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Test
if: github.event_name != 'push'
run: |
cd $CONTEXT
docker-compose -f docker-compose.test.yaml up --build --no-deps --abort-on-container-exit --exit-code-from scilog
docker-compose -f docker-compose.test.yaml down
- name: Login to GHCR
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags
id: tags
run: |
prefix=$CONTAINER_REGISTRY/$IMAGE_NAME
tags=$prefix:"${{ github.sha }}"
if [[ "${{ github.event_name }}" == "release" ]]; then
tags=$prefix:"${{ github.event.release.tag_name }}",$prefix:stable
fi
echo "tags=$tags,$prefix:latest" >> $GITHUB_OUTPUT
- name: Build
uses: docker/build-push-action@v3
with:
context: ${{ env.CONTEXT }}/.
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}