-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.79 KB
/
docker-push.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
name: Docker Build and Push
on:
push:
branches:
- main
- dev/*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image
run: docker build -t ${{ secrets.K8S_DOCKER_REGISTHOST }}/unibot:latest .
id: build
- name: Save Docker image to file
run: docker save ${{ secrets.K8S_DOCKER_REGISTHOST }}/unibot:latest -o image-file.tar
- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: container-image
path: image-file.tar
retention-days: 1
push:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: container-image
path: .
- name: Load Docker image from file
run: docker load -i image-file.tar
- name: Set Docker configuration
run: |
SW_JSON=""
SW_JSON="$(sudo cat /etc/docker/daemon.json | jq '.+{ "insecure-registries":["${{ secrets.K8S_DOCKER_REGISTHOST }}"],"max-concurrent-uploads": 1,"debug":true }')"
echo "${SW_JSON}" | sudo bash -c 'cat -- > /etc/docker/daemon.json'
sudo cat /etc/docker/daemon.json
sudo systemctl restart docker || sudo journalctl -xeu docker.service
echo ---
docker info
echo ---
docker image ls
echo ---
sudo systemctl status docker
shell: bash
- name: Push Docker image
run: docker push ${{ secrets.K8S_DOCKER_REGISTHOST }}/unibot:latest