-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (96 loc) · 3.04 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
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
name: Docker Image CI
#on: [push, pull_request]
on:
push:
branches:
- test
- main
- dev
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 🛎️
uses: actions/checkout@v3
- name: Install Python 3.9 🐍
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Set up runner 📦
run: pip3 install black==24.4.2
- name: "Black: Code Formatting 👮🏽♀️"
run: black --diff . && black -v --check .
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Determine Docker tag
id: docker-tag
run: |
if [[ $GITHUB_REF == refs/heads/main ]]; then
echo "::set-output name=tag::latest"
elif [[ $GITHUB_REF == refs/heads/dev ]]; then
echo "::set-output name=tag::dev"
elif [[ $GITHUB_REF == refs/heads/test ]]; then
echo "::set-output name=tag::testing"
else
echo "Branch does not match any predefined tags. Exiting."
exit 1
fi
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./
file: ./environments/Dockerfile
push: true
tags: buntha/pybalance:${{ steps.docker-tag.outputs.tag }}
# base_image:
# name: Base Image for standard environment
# runs-on: ubuntu-latest
# needs: linting
#
# steps:
# - name: Checkout Repository 🛎️
# uses: actions/checkout@v3
# - name: Create tag name 🆔
# run: echo "DOCKER_TAG=$(echo "${{ github.ref_name }}" | sed -E 's/[^[:alnum:].-]+/-/g' | sed -E 's/^[^[:alnum:]]+//')" >> $GITHUB_ENV
# - name: docker
# run: docker build -t ${DOCKER_TAG} -f environments/Dockerfile .
# - name: Pytest
# run: docker run ${DOCKER_TAG} pytest
#
# base_image_gpu:
# name: Base Image for GPU environment
# runs-on: ubuntu-latest
# needs: linting
#
# steps:
# - name: Checkout Repository 🛎️
# uses: actions/checkout@v3
# - name: Create tag name 🆔
# run: echo "DOCKER_TAG=$(echo "${{ github.ref_name }}-gpu" | sed -E 's/[^[:alnum:].-]+/-/g' | sed -E 's/^[^[:alnum:]]+//')" >> $GITHUB_ENV
# - name: docker
# run: docker build -t ${DOCKER_TAG} -f environments/Dockerfile.gpu .
# - name: Pytest
# run: docker run ${DOCKER_TAG} pytest