-
Notifications
You must be signed in to change notification settings - Fork 1
/
full-pipeline.yaml
146 lines (122 loc) · 5.7 KB
/
full-pipeline.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
### The OpenShift Starter workflow will:
# - Checkout your repository
# - Perform a Docker build
# - Push the built image to an image registry
# - Log in to your OpenShift cluster
# - Create an OpenShift app from the image and expose it to the internet.
### Before you begin:
# - Have write access to a container image registry such as quay.io or Dockerhub.
# - Have access to an OpenShift cluster.
# - For instructions to get started with OpenShift see https://www.openshift.com/try
# - The project you wish to add this workflow to should have a Dockerfile.
# - If you don't have a Dockerfile at the repository root, see the buildah-build step.
# - Builds from scratch are also available, but require more configuration.
### To get the workflow running:
# 1. Add this workflow to your repository.
# 2. Edit the top-level 'env' section, which contains a list of environment variables that must be configured.
# 3. Create the secrets referenced in the 'env' section under your repository Settings.
# 4. Edit the 'branches' in the 'on' section to trigger the workflow on a push to your branch.
# 5. Commit and push your changes.
# For a more sophisticated example, see https://github.com/redhat-actions/spring-petclinic/blob/main/.github/workflows/petclinic-sample.yaml
# Also see our GitHub organization, https://github.com/redhat-actions/
# ▶️ See a video of how to set up this workflow at https://www.youtube.com/watch?v=6hgBO-1pKho
name: OpenShift
# ⬇️ Modify the fields marked with ⬇️ to fit your project, and create any secrets that are referenced.
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
env:
# ⬇️ EDIT with your registry and registry path.
QUAY_REGISTRY: quay.io/repository/opsumo/polkadot
# ⬇️ EDIT with your registry username.
QUAY_REGISTRY_USER: ${{ secrets.QUAY_USERNAME }}
QUAY_REGISTRY_PASSWORD: ${{ secrets.QUAI_REGISTRY_PASSWORD }}
DOCKER_REGISTRY: hub.docker.com/repository/docker/edmcbee
DOCKER_REGISTRY_USER: edmcbee
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
# ⬇️ EDIT to log into your OpenShift cluster and set up the context.
# See https://github.com/redhat-actions/oc-login#readme for how to retrieve these values.
#OPENSHIFT_SERVER: ${{ secrets.RHOCP_DEV_CLUSTER }}
#OPENSHIFT_TOKEN: ${{ secrets.RHOCP_DEV_TOKEN }}
OPENSHIFT_SERVER: https://ocp.ellipticurve.com:8443
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
#oc login https://ocp.ellipticurve.com:8443 --token=A5--Rkmwua5o6pIfc2Gjx8Cg3GL2vkGwihgOoMWbadk
# ⬇️ EDIT with any additional port your application should expose.
# By default, oc new-app action creates a service to the image's lowest numeric exposed port.
APP_PORT: "9944"
# ⬇️ EDIT if you wish to set the kube context's namespace after login. Leave blank to use the default namespace.
#OPENSHIFT_NAMESPACE: "edmacabebe_dev"
OPENSHIFT_NAMESPACE: "polkadot"
# If you wish to manually provide the APP_NAME and TAG, set them here, otherwise they will be auto-detected.
APP_NAME: "polkadot"
TAG: "latest"
on:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
push:
# Edit to the branch(es) you want to build and deploy on each push.
branches: [ develop ]
jobs:
openshift-ci-cd:
name: Build and deploy to OpenShift
runs-on: ubuntu-18.04
environment: staging
outputs:
ROUTE: ${{ steps.deploy-and-expose.outputs.route }}
SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }}
steps:
######DOCKER BUILD
- name: Github checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Build
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Dockerhub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
file: deploy-chain-0/polkadot/docker/Dockerfile
tags: |
edmcbee/polkadot:latest
build-args: |
POLKADOT_VERSION=${{ github.event.release.tag_name }}
VCS_REF=${{ github.ref }}
BUILD_DATE=${{ github.event.release.published_at }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
######DOCKER BUILD
######CICD to OCP
- name: Install oc
uses: redhat-actions/oc-installer@v1
with:
oc_version: '4.6'
- name: Log in to OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_SERVER }}
openshift_token: ${{ env.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
- name: Do print Openshift URL
run: echo ${{ env.OPENSHIFT_SERVER }}
- name: Deploy to Project
id: new-project-namespace
run: oc --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} rollout latest dc/polkadot -n polkadot
######CICD to OCP