-
Notifications
You must be signed in to change notification settings - Fork 9
106 lines (91 loc) · 3.06 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Docker Publish
on:
workflow_run:
workflows: ["CI Build"]
types:
- completed
jobs:
docker:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download event type file
uses: actions/download-artifact@v4
with:
name: event
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GH_TOKEN }}
path: ./
- name: Download dingofs artifact
uses: actions/download-artifact@v4
with:
name: dingofs
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GH_TOKEN }}
path: ./
- name: Config trigger event env
run: |
if [ -f event.txt ]; then
echo "EVENT=$(cat event.txt)" >> $GITHUB_ENV
fi
- name: Download tag name file
if: ${{ env.EVENT == 'tag' }}
uses: actions/download-artifact@v4
with:
name: tag_name
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GH_TOKEN }}
path: ./
- name: Config push tag env
if: ${{ env.EVENT == 'tag' }}
run: |
if [ -f tag_name.txt ]; then
echo "TAG_NAME=$(cat tag_name.txt)" >> $GITHUB_ENV
fi
- name: Print env info
id: check-event
run: |
echo "trigger event type is ${{ env.EVENT }}"
echo "continue=true" >> $GITHUB_OUTPUT
if [ "${{ env.EVENT }}" == "pull_request" ]; then
echo "pull request haven't merged, not need to publish image."
echo "continue=false" >> $GITHUB_OUTPUT
fi
if [ -n "${{ env.TAG_NAME }}" ]; then
echo "tag name is ${{ env.TAG_NAME }}, need to publish image."
fi
- name: List directory contents after download
if: steps.check-event.outputs.continue == 'true'
run: ls -la
- name: Extract artifact
if: steps.check-event.outputs.continue == 'true'
run: tar -xzvf dingofs.tar.gz -C dingofs/docker/rocky9
- name: Set up Docker Buildx
if: steps.check-event.outputs.continue == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: steps.check-event.outputs.continue == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
if: steps.check-event.outputs.continue == 'true'
id: meta
uses: docker/metadata-action@v5
with:
images: dingodatabase/dingofs
tags: |
type=raw,enable=${{ env.EVENT == 'tag' }},value=${{ env.TAG_NAME }}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=,format=long
- name: Build and push
if: steps.check-event.outputs.continue == 'true'
uses: docker/build-push-action@v6
with:
context: ./dingofs/docker/rocky9
file: ./dingofs/docker/rocky9/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}