forked from satishweb/docker-doh
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (38 loc) · 1.42 KB
/
docker-build.yaml
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
name: Docker Image CI
on:
push:
tags:
- "v*"
env:
IMAGE_NAME: docker-doh
DOCKERHUB_IMAGE: showfom/doh-server
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build image
run: docker build . --file Dockerfile.alpine --tag "$IMAGE_NAME" --label "runnumber=${GITHUB_RUN_ID}"
- name: Push image
run: |
IMAGE_ID="ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME"
IMAGE_VERSION="${GITHUB_REF##*/v}"
docker tag "$IMAGE_NAME" "$IMAGE_ID:$IMAGE_VERSION"
docker tag "$IMAGE_NAME" "$IMAGE_ID:latest"
docker push "$IMAGE_ID:$IMAGE_VERSION"
docker push "$IMAGE_ID:latest"
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push image
run: |
IMAGE_ID="$DOCKERHUB_IMAGE"
IMAGE_VERSION="${GITHUB_REF##*/v}"
docker tag "$IMAGE_NAME" "$IMAGE_ID:$IMAGE_VERSION"
docker tag "$IMAGE_NAME" "$IMAGE_ID:latest"
docker push "$IMAGE_ID:$IMAGE_VERSION"
docker push "$IMAGE_ID:latest"