-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (53 loc) · 1.74 KB
/
docker-image.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
# .github/workflows/docker-image.yml
name: Build, Test, and Push Docker Image
on:
push:
branches:
- main
- 'prerelease-*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set repository name to lowercase
id: lowercase_repo
run: echo "REPO=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Determine Docker tag
id: get_tag
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF}" == refs/heads/prerelease-* ]]; then
echo "tag=prerelease" >> $GITHUB_OUTPUT
else
echo "tag=prerelease" >> $GITHUB_OUTPUT
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: |
python -m unittest discover tests
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ steps.lowercase_repo.outputs.REPO }}/tasks:${{ steps.get_tag.outputs.tag || 'prerelease' }}