-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (57 loc) · 1.93 KB
/
01-ci-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
name: 🐋 Docker image ci
on:
push:
paths: [docker/**]
branches: [main]
pull_request:
paths: [docker/**]
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: 📦 Build docker image
runs-on: ubuntu-20.04
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v3
- name: 🚀 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: 📦 Build Docker image and export
uses: docker/build-push-action@v3
with:
context: docker
tags: ${{ secrets.DOCKERHUB_REPO }}:${{ github.run_number }}, ${{ secrets.DOCKERHUB_REPO }}:latest
outputs: type=docker,dest=/tmp/docker-image-${{ github.run_number }}.tar.gz
- if: github.event_name == 'push'
name: ⬆ Upload artifact
uses: actions/upload-artifact@v3
with:
name: docker-image-${{ github.run_number }}.tar.gz
path: /tmp/docker-image-${{ github.run_number }}.tar.gz
publish:
if: github.event_name == 'push'
name: 💭 Publish Docker image
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: 🚀 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: ⤵️ Download artifact
uses: actions/download-artifact@v3
with:
name: docker-image-${{ github.run_number }}.tar.gz
path: /tmp/
- name: 🐋 Load image
run: |
docker load -i /tmp/docker-image-${{ github.run_number }}.tar.gz
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN}}
- name: 💭 Publish image
run: |
docker push ${{ secrets.DOCKERHUB_REPO }}:${{ github.run_number }}
docker push ${{ secrets.DOCKERHUB_REPO }}:latest