Captain Ezio commited on
Commit
77e8a60
·
1 Parent(s): c9d8b5f

Create docker-build.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/docker-build.yml +74 -0
.github/workflows/docker-build.yml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Docker Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - Dockerfile
9
+ - docker-entrypoint.sh
10
+ - .github/workflows/docker-build.yml
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ build:
15
+ name: Build Image
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ packages: write
19
+ contents: read
20
+
21
+ steps:
22
+ - name: Checkout current repo
23
+ uses: actions/checkout@v2
24
+
25
+ - name: Login to GitHub Container Registry
26
+ uses: docker/login-action@v1
27
+ with:
28
+ registry: ghcr.io
29
+ username: ${{ github.actor }}
30
+ password: ${{ secrets.GITHUB_TOKEN }}
31
+
32
+ - name: Login to DockerHub
33
+ uses: docker/login-action@v1
34
+ with:
35
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
36
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
37
+
38
+ - name: Set ENV Variables
39
+ run: |
40
+ IMG="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
41
+ bot_git_version=$(git rev-parse --short HEAD)
42
+ echo "BUILD_VER=bot_git_version" >> $GITHUB_ENV
43
+ echo "IMAGE=${IMG}" >> $GITHUB_ENV
44
+ echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
45
+ echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
46
+ echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
47
+ - name: Set up QEMU
48
+ uses: docker/setup-qemu-action@v1
49
+
50
+ - name: Set up Docker Buildx
51
+ uses: docker/setup-buildx-action@v1
52
+
53
+ - name: Build and push
54
+ id: docker_build
55
+ uses: docker/build-push-action@v2
56
+ with:
57
+ context: .
58
+ platforms: linux/amd64,linux/arm64
59
+ push: true
60
+ cache-from: type=gha
61
+ cache-to: type=gha,mode=max
62
+ tags: |
63
+ ghcr.io/${{ env.IMAGE }}:latest
64
+ ghcr.io/${{ env.IMAGE }}:${{ env.BUILD_VER }}
65
+ ${{ env.IMAGE }}:latest
66
+ ${{ env.IMAGE }}:${{ env.BUILD_VER }}
67
+ labels: |
68
+ org.opencontainers.image.authors=${{ github.repository_owner }}
69
+ org.opencontainers.image.created=${{ env.BUILD_DATE }}
70
+ org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
71
+ org.opencontainers.image.ref.name=${{ env.GIT_REF }}
72
+ org.opencontainers.image.revision=${{ github.sha }}
73
+ org.opencontainers.image.source=https://github.com/${{ github.repository }}
74
+ org.opencontainers.image.version=${{ env.BUILD_VER }}