-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.41 KB
/
main.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: Test and Build Docker image
on:
push:
tags:
- '*'
jobs:
test:
runs-on: ubuntu-latest
container:
image: python:3.11
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- shell: bash
run: |
echo $GITHUB_REF_NAME | grep -oE '^([0-9]+\.){2}[0-9]+$' || (echo "ERROR: Invalid tag format, should be a three part version number (e.g. 1.2.3)" && exit 1)
./install.dev.sh
source .env/bin/activate
./test.sh
timeout-minutes: 2
build_docker_image:
needs: test
runs-on: ubuntu-latest
container:
image: docker:20
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- env:
CI_REGISTRY_USER: ${{ github.actor }}
CI_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
CI_REGISTRY: ghcr.io
CI_REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
run: |
echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
IMAGE_TAG=$(echo "$CI_REGISTRY_IMAGE:$GITHUB_REF_NAME" | tr [:upper:] [:lower:])
if docker pull $IMAGE_TAG > /dev/null 2>&1; then echo "ERROR: An image with the given tag already exists. Please increment the contents of the VERSION file" && exit 1; fi
docker build . -t $IMAGE_TAG
docker push $IMAGE_TAG
timeout-minutes: 5