-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (71 loc) · 2.27 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
name: Push to registry
on:
push:
tags:
- 'v*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: http://registry.ellite.dev/
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: registry.ellite.dev/raibu-web:${{ steps.get_version.outputs.VERSION }}
- name: Check if tag is the latest
id: check_latest
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const tags = await github.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
});
const versions = tags.data.map(tag => tag.name).sort((a, b) => semver.rcompare(a, b));
return versions[0] === '${{ steps.get_version.outputs.VERSION }}';
- name: Build and push latest
if: steps.check_latest.outputs.result == 'true'
uses: docker/build-push-action@v5
with:
push: true
tags: registry.ellite.dev/raibu-web:latest
- name: Test image
run: |
docker pull registry.ellite.dev/raibu-web:${{ steps.get_version.outputs.VERSION }}
if [ $? -eq 0 ]; then
echo "Image exists"
else
echo "Image does not exist"
exit 1
fi
tarball:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create copy of workspace
run: |
mkdir ../temp_workspace
cp -r . ../temp_workspace
- name: Create tarball
run: |
tar --exclude='./.git' -czvvf raibu-web.tar.gz ../temp_workspace
- name: Upload tarball
uses: actions/upload-artifact@v2
with:
name: raibu-web
path: raibu-web.tar.gz