-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (60 loc) · 2.81 KB
/
ci-python-build.yml
File metadata and controls
66 lines (60 loc) · 2.81 KB
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
name: build-python-app
on:
push:
branches:
tags:
paths:
- ".github/workflows/ci-python-build.yml"
- "python/**"
pull_request:
paths:
- ".github/workflows/ci-python-build.yml"
- "python/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: build and push latest to docker.com and ghcr.io
if: ${{ startsWith(github.ref, 'refs/heads/') }}
env:
DOCKER_REGISTRY_USERNAME: ${{ github.actor }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
GH_REGISTRY_USERNAME: ${{ github.actor }}
GH_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_TOKEN }}
run: |
version=snapshot
revision=${GITHUB_SHA:0:7}
ref_name=${GITHUB_REF#refs/*/}
now=$(date --rfc-3339=seconds --utc)
echo PUBLISH VERSION: ${version}
echo ${GH_REGISTRY_TOKEN} | docker login ghcr.io -u ${GH_REGISTRY_USERNAME} --password-stdin
echo ${DOCKER_REGISTRY_TOKEN} | docker login -u ${DOCKER_REGISTRY_USERNAME} --password-stdin
docker buildx build --push \
--build-arg VERSION=${version} --build-arg REVISION=${revision} --build-arg REF_NAME=${ref_name} --build-arg CREATED="${now}" \
-t ghcr.io/${GH_REGISTRY_USERNAME}/git-helper:${version} -t ${DOCKER_REGISTRY_USERNAME}/git-helper:${version} \
--file build/Dockerfile python
- name: build and push tag and latest to docker.com and ghcr.io
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
DOCKER_REGISTRY_USERNAME: ${{ github.actor }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
GH_REGISTRY_USERNAME: ${{ github.actor }}
GH_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_TOKEN }}
run: |
version=${GITHUB_REF#refs/tags/v}
revision=${GITHUB_SHA:0:7}
ref_name=${GITHUB_REF#refs/*/}
now=$(date --rfc-3339=seconds --utc)
echo PUBLISH VERSION: ${version} latest
echo ${GH_REGISTRY_TOKEN} | docker login ghcr.io -u ${GH_REGISTRY_USERNAME} --password-stdin
echo ${DOCKER_REGISTRY_TOKEN} | docker login -u ${DOCKER_REGISTRY_USERNAME} --password-stdin
docker buildx build --push \
--build-arg VERSION=${version} --build-arg REVISION=${revision} --build-arg REF_NAME=${ref_name} --build-arg CREATED="${now}" \
-t ghcr.io/${GH_REGISTRY_USERNAME}/git-helper:${version} -t ${DOCKER_REGISTRY_USERNAME}/git-helper:${version} \
-t ghcr.io/${GH_REGISTRY_USERNAME}/git-helper:latest -t ${DOCKER_REGISTRY_USERNAME}/git-helper:latest \
--file build/Dockerfile python