-
Notifications
You must be signed in to change notification settings - Fork 7
92 lines (82 loc) · 3.19 KB
/
docker-publish.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
name: Build and Publish Docker Image
on:
push:
branches: [main]
tags:
- '*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Compute Version and Commit Info
id: cpfinfo
run: |
VERSION=$(cat sourcecode-parser/VERSION)
COMMIT=$(git describe --tags)
echo $VERSION
echo $COMMIT
echo "PROJECT_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "PROJECT_COMMIT=${COMMIT}" >> $GITHUB_OUTPUT
- name: Determine Docker Tag
id: vars
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=$(cat sourcecode-parser/VERSION)
echo "tag1=v${VERSION}" >> $GITHUB_OUTPUT
echo "tag2=stable-latest" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
VERSION=$(cat sourcecode-parser/VERSION)
echo "tag1=dev-${VERSION}" >> $GITHUB_OUTPUT
echo "tag2=nightly-latest" >> $GITHUB_OUTPUT
else
echo "tag1=dev" >> $GITHUB_OUTPUT
echo "tag2=nightly-dev" >> $GITHUB_OUTPUT
fi
- name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v5
env:
POSTHOG_WEB_ANALYTICS: ${{ secrets.POSTHOG_WEB_ANALYTICS }}
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
POSTHOG_WEB_ANALYTICS=${{ secrets.POSTHOG_WEB_ANALYTICS }}
PROJECT_COMMIT=${{ steps.cpfinfo.outputs.PROJECT_COMMIT }}
PROJECT_VERSION=${{ steps.cpfinfo.outputs.PROJECT_VERSION }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/code-pathfinder:${{ steps.vars.outputs.tag1 }}
ghcr.io/${{ github.repository_owner }}/code-pathfinder:${{ steps.vars.outputs.tag2 }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v5
env:
POSTHOG_WEB_ANALYTICS: ${{ secrets.POSTHOG_WEB_ANALYTICS }}
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
POSTHOG_WEB_ANALYTICS=${{ secrets.POSTHOG_WEB_ANALYTICS }}
PROJECT_COMMIT=${{ steps.cpfinfo.outputs.PROJECT_COMMIT }}
PROJECT_VERSION=${{ steps.cpfinfo.outputs.PROJECT_VERSION }}
tags: |
${{ secrets.DOCKER_USERNAME }}/code-pathfinder:${{ steps.vars.outputs.tag1 }}
${{ secrets.DOCKER_USERNAME }}/code-pathfinder:${{ steps.vars.outputs.tag2 }}