-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (40 loc) · 1.35 KB
/
publish-main.yml
File metadata and controls
49 lines (40 loc) · 1.35 KB
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
name: Build and Push Runtime Image
on:
push:
branches: [main]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set repo owner lowercase
run: echo "OWNER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Get date tag with increment
run: |
DATE=$(date +'%Y%m%d')
REPO=ghcr.io/${OWNER}/racebot
n=0
while docker manifest inspect "$REPO:$DATE".$n > /dev/null 2>&1; do
n=$((n+1))
done
TAG="${DATE}.$n"
echo "TAG=$TAG" >> $GITHUB_ENV
echo "Tag to use: $TAG"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build runtime image
run: |
docker build --target runtime -t ghcr.io/${OWNER}/racebot:${TAG} .
docker tag ghcr.io/${OWNER}/racebot:${TAG} ghcr.io/${OWNER}/racebot:latest
- name: Push runtime image (latest)
run: |
docker push ghcr.io/${OWNER}/racebot:${TAG}
docker push ghcr.io/${OWNER}/racebot:latest