-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.25 KB
/
gitops.yaml
File metadata and controls
105 lines (89 loc) · 3.25 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
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
###
name: Build Step
on:
push:
branches: ['master']
# pull_request:
# branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.20.0]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
test-stage:
runs-on: ubuntu-latest
needs: build
steps:
- name: Running Tests
uses: actions/checkout@v3
- run: echo "runnigngngngngn"
build-and-push-docker-image:
name: Build Docker image and push to repositories
# run only when code is compiling and tests are passing
runs-on: ubuntu-latest
needs: ['build', 'test-stage']
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v3
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.G_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: ./
# Note: tags has to be all lower-case
tags: |
mohsin1056/gitops01:${{ github.sha }}
ghcr.io/mohsin1960/gitops01:${{ github.sha }}
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/master' }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
update-manifest-stage:
runs-on: ubuntu-latest
needs: ['build-and-push-docker-image']
steps:
- uses: actions/checkout@v3
with:
repository: mohsin1960/gitops-argoCD-infra-yaml
ref: 'master'
token: ${{ secrets.G_TOKEN }}
- name: setup git config
run: |
git config --global user.email "i201960@nu.edu.pk"
git config --global user.name "mohsin1960"
echo ${{ github.sha }}
#sed -i "s#${{ github.actor }}.*#${{ github.actor }}/gitops01:${{ github.sha }}#g" deployment.yaml
sed -i "s#image: mohsin1056/gitops01:.*#image: mohsin1056/gitops01:${{ github.sha }}#g" deployment.yaml
git add -A
git commit -am "Update image for - ${{ github.sha }}"
- run: echo ${{ github }}
- run: git push origin master