-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (56 loc) · 2.38 KB
/
maven.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
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Maven
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x mvnw
- name: Run the Maven verify phase
run: mvn --batch-mode --update-snapshots verify
- name: Build with Maven
run: ./mvnw package
- name: set environment variable APP_DOCKER_REPO
id: set-env-APP_DOCKER_REPO
run: |
echo "APP_DOCKER_REPO=maxmorev/paypal-rest-api" >> $GITHUB_ENV
- name: Print name for docker repository
run: echo ${APP_DOCKER_REPO}
- name: Build and push Docker image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{env.APP_DOCKER_REPO}}
tags: 0.0.${{ github.run_number }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Update deployment file
run: TAG=0.0.$(echo ${{ github.run_number }} | head -c7) && sed -i 's|${{env.APP_DOCKER_REPO}}:latest|${{env.APP_DOCKER_REPO}}:'${TAG}'|' $GITHUB_WORKSPACE/k8s-deployment.yaml
# UPDATE SECRETS
- name: Update k8s-secrets PAYPAL_CLIENT_ID
run: sed -i 's|{PAYPAL_CLIENT_ID}|${{secrets.PAYPAL_CLIENT_ID}}|' $GITHUB_WORKSPACE/k8s-secrets.yaml
- name: Update k8s-secrets PAYPAL_SECRET
run: sed -i 's|{PAYPAL_SECRET}|${{secrets.PAYPAL_SECRET}}|' $GITHUB_WORKSPACE/k8s-secrets.yaml
- name: Print image version
run: cat $GITHUB_WORKSPACE/k8s-deployment.yaml | grep image
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save k8s-eshop
#k8s deploy
- name: Deploy to DigitalOcean Kubernetes secrets
run: kubectl apply -f $GITHUB_WORKSPACE/k8s-secrets.yaml
- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -f $GITHUB_WORKSPACE/k8s-deployment.yaml