-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 1.87 KB
/
github_cicd.yaml
File metadata and controls
64 lines (52 loc) · 1.87 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
name: Employee CI/CD
on: push
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
ANSWER: 0
NUM1: 0
NUM2: 0
TOKEN:
STATUS:
jobs:
build-and-upload-to-docker-hub:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./src
file: ./src/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/employee-management-app:${{ github.run_number }}
fake-deployment:
runs-on: ubuntu-latest
steps:
- name: get-challenge-tokens
run: |
touch challenge.json && curl https://fdeployserver.up.railway.app/challenge > ./challenge.json && echo ::set-env name=TOKEN::$(jq '.token' challenge.json) && echo ::set-env name=NUM1::$(jq '.num1' challenge.json) && echo ::set-env name=NUM2::$(jq '.num2' challenge.json)
- name: sum-numbers
run: |
echo ::set-env name=ANSWER::$(($NUM1 + $NUM2))
- name: printing-variables
run: echo "$TOKEN" && echo "$NUM1" && echo "$NUM2"
- name: deploy-numbers
run: |
touch response.txt && curl -X POST 'https://fdeployserver.up.railway.app/deploy' --header 'Content-Type:application/json' -d '{"token":$(TOKEN), "answer":$(ANSWER)}' > ./response.txt
echo ::set-env name=STATUS::$(cat response.txt)
- name: print-status
run: echo "$STATUS"
fake-deployment-try2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Running python script
run: python3 deployserver.py