forked from druv5319/Sneaks-API
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 3.32 KB
/
docker-build-push-master.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
75
76
# This is a basic workflow to help you get started with Actions
name: Build and push Master image to DockerHub
# Controls when the workflow will run
on:
push:
branches: [master]
# Allow running workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Docker Login
# You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/[email protected]
with:
# Username used to log against the Docker registry
username: ${{ secrets.DOCKER_HUB_USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.DOCKER_HUB_TOKEN }}
# Log out from the Docker registry at the end of a job
logout: true # optional, default is true
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Set up Docker builder
id: buildx
uses: docker/[email protected]
- name: Print new build number
run: echo "Build number is ${GITHUB_RUN_NUMBER}"
- name: Extract build number
shell: bash
run: echo "##[set-output name=build_number;]$(echo ${GITHUB_RUN_NUMBER})"
id: buildnumber
- name: Print new build number
run: echo "Build number is $BUILD_NUMBER"
- name: Build and push development image
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
# The test image is /docker and is private. final image will be /calendso and public
tags: |
docker.io/breadwinnerinc/copyt-sneaks:master
docker.io/breadwinnerinc/copyt-sneaks:master-${{ steps.buildnumber.outputs.build_number }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Deploy to Rancher
run: |
curl -u "${{ secrets.RANCHER_API }}" \
-X PATCH \
-H 'Content-Type: application/json-patch+json' \
https://rancher-sys.krum.io/k8s/clusters/c-hw822/apis/apps/v1/namespaces/development/deployments/platform-sneaks-api \
-d '[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "breadwinnerinc/copyt-sneaks:master-${{ steps.buildnumber.outputs.build_number }}"}]' \