-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (62 loc) · 2.37 KB
/
deploy_docker.yaml
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
on:
push:
branches:
- "main"
- "humble"
jobs:
deploy-main-image:
name: Build and deploy main docker image
runs-on: ubuntu-latest
env:
PLATFORM: linux/amd64
MAIN_IMAGE: ghcr.io/${{ github.repository_owner }}/firo_robot
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract branch name
run: echo "BRANCH=$(git rev-parse --abbrev-ref HEAD)" >>${GITHUB_ENV}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install -D semantic-release @semantic-release/exec conventional-changelog-conventionalcommits
- name: Tag version
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release -t "${{env.BRANCH}}-\${version}"
# github.repository_owner can contain uppercase chars,
# but docker repository address must be all lowercase
- name: lowercase image name
if: ${{ steps.semantic-release.outputs.next_version || false }}
run: |
echo "MAIN_IMAGE=${MAIN_IMAGE,,}" >>${GITHUB_ENV}
- name: Set up QEMU
if: ${{ steps.semantic-release.outputs.next_version || false }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ steps.semantic-release.outputs.next_version || false }}
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: ${{ steps.semantic-release.outputs.next_version || false }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push image
if: ${{ steps.semantic-release.outputs.next_version || false }}
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: true
provenance: false # Remove in the future. Currently ghcr does not parse it correctly
tags: |
${{ env.MAIN_IMAGE }}:${{env.BRANCH}}-${{steps.semantic-release.outputs.next_version}}
${{ env.MAIN_IMAGE }}:${{env.BRANCH}}
platforms: ${{ env.PLATFORM }}
cache-from: ${{ env.MAIN_IMAGE }}:${{env.BRANCH}}
build-args: BUILDKIT_INLINE_CACHE=1