-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (64 loc) · 1.96 KB
/
dockerimage.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
# gokaygurcan/dockerfile-nginx
name: nginx
on:
push:
pull_request:
branches:
- main
env:
GITHUB: ${{ toJson(github) }}
jobs:
version:
name: Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
name: Version
run: |
grep -r "NGINX_VERSION=" Dockerfile | cut -d "=" -f 2 | cut -d " " -f 1
echo "::set-output name=version::$(grep -r "NGINX_VERSION=" Dockerfile | cut -d "=" -f 2 | cut -d " " -f 1)"
nginx:
name: nginx
runs-on: ubuntu-latest
env:
CI: true
steps:
- id: sanity-check
name: Sanity check
run: |
printenv
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: login
name: Login to Docker Hub
uses: docker/login-action@v2
if: |
github.ref == 'refs/heads/main'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: build
name: Build image
run: |
docker build --file Dockerfile --tag gokaygurcan/nginx:latest --tag gokaygurcan/nginx:${{ steps.version.outputs.version }} .
docker ps -a
- id: test
name: Test
run: |
docker volume create usr-share-geoip
docker run --rm --name geoipupdate -v usr-share-geoip:/usr/share/GeoIP -e GEOIPUPDATE_FREQUENCY=0 -e GEOIPUPDATE_ACCOUNT_ID='${{ secrets.GEOIPUPDATE_ACCOUNT_ID }}' -e GEOIPUPDATE_LICENSE_KEY='${{ secrets.GEOIPUPDATE_LICENSE_KEY }}' -e GEOIPUPDATE_EDITION_IDS='GeoLite2-City GeoLite2-Country' maxmindinc/geoipupdate
docker run --rm --name nginx gokaygurcan/nginx nginx -V
- id: push
name: Push to Docker Registry
uses: docker/build-push-action@v3
if: |
github.ref == 'refs/heads/main'
with:
context: .
push: true
tags: |
gokaygurcan/nginx:latest
gokaygurcan/nginx:${{ steps.version.outputs.version }}