-
-
Notifications
You must be signed in to change notification settings - Fork 28
166 lines (156 loc) · 5.52 KB
/
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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: nanosaur builder
# Reference:
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on: [push, workflow_dispatch]
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
docker_image_name: nanosaur/nanosaur
# https://github.com/docker/build-push-action
jobs:
test-pkgs:
name: "Test packages and version"
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs
outputs:
tag: ${{ steps.repo_status.outputs.tag }}
pre_release: ${{ steps.repo_status.outputs.pre_release }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout nanosaur tools repo
uses: actions/checkout@v4
with:
repository: rnanosaur/nanosaur_tools
path: nanosaur_tools
- name: Repository status
id: repo_status
shell: bash
run: |
pip3 install -r nanosaur_tools/CI/requirements.txt
if ${{ startsWith(github.ref, 'refs/tags/') }} ; then
TAG_RELEASE=${GITHUB_REF/refs\/tags\//}
else
TAG_RELEASE=${GITHUB_REF/refs\/heads\//}
fi
CHECK_PRE_RELEASE=$(python3 nanosaur_tools/check_pre_release.py $TAG_RELEASE)
echo ::set-output name=tag::${TAG_RELEASE}
echo ::set-output name=pre_release::${CHECK_PRE_RELEASE}
echo "tag=${TAG_RELEASE}"
echo "pre_release=${CHECK_PRE_RELEASE}"
- name: Test version packages
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
TAG_RELEASE=${{ steps.repo_status.outputs.tag }}
python3 nanosaur_tools/check_tag_version.py $TAG_RELEASE
echo "Check nanosaur script"
python3 nanosaur_tools/check_nanosaur_script.py $TAG_RELEASE
# https://github.com/docker/build-push-action/issues/225
docker:
name: "Build Docker image develop"
runs-on: ubuntu-latest
steps:
# https://github.com/docker/build-push-action/blob/master/docs/advanced/tags-labels.md
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.docker_image_name }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=ref,event=tag
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.actor != 'dependabot[bot]'
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
push: ${{ github.actor != 'dependabot[bot]' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64
- name: Docker Image digest
run: |
echo ${{ steps.docker_build.outputs.digest }}
export:
name: Make all artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build project
run: |
bash nanosaur_description/scripts/nanosaur_stl.sh
- name: upload data
uses: actions/upload-artifact@v3
with:
name: data
path: |
nanosaur-stl.zip
nanosaur_description/meshes/datasheet/nanosaur-powerbank.pdf
nanosaur_description/meshes/datasheet/nanosaur-datasheet.pdf
nanosaur/scripts/nanosaur
update_docker_description:
name: Update docker description
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [docker]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Hub Description # https://github.com/peter-evans/dockerhub-description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: nanosaur/nanosaur
short-description: ${{ github.event.repository.description }}
readme-filepath: ./README.md
new_release:
name: Upload release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [test-pkgs, export]
steps:
- name: Extract artifact
uses: actions/download-artifact@v3
with:
name: data
- name: Release # https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref }}
name: Release ${{ needs.test-pkgs.outputs.tag }}
generate_release_notes: true
draft: false
prerelease: ${{ needs.test-pkgs.outputs.pre_release }}
files: |
nanosaur-stl.zip
nanosaur_description/meshes/datasheet/nanosaur-powerbank.pdf
nanosaur_description/meshes/datasheet/nanosaur-datasheet.pdf
nanosaur/scripts/nanosaur
notify:
name: "Notify socials"
needs: [test-pkgs, new_release, update_docker_description]
runs-on: ubuntu-latest
steps:
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**${{ env.docker_image_name }}:${{ needs.test-pkgs.outputs.tag }}** has been deployed!'