-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (34 loc) · 1.44 KB
/
apprentice-action-test.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
name: Build-Test-Push
on:
push:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: fetch code
uses: actions/checkout@v2
- name: build Docker image
run: docker build -t test-image .
- name: run Docker container
run: docker run -d -p 80:80 test-image
- name: run tests
uses: liatrio/github-actions/apprentice-action@808117af9b4a1e57c4cb79dbcb2d25de5ea3c68d
- name: log in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USER_NAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: list Docker images(debug)
run: docker images
- name: tag Docker image
run: docker tag test-image ${{ secrets.DOCKER_USER_NAME }}/test-image
- name: push Docker image to Docker Hub
run: docker push ${{ secrets.DOCKER_USER_NAME }}/test-image
- name: authenticate and login to Google Cloud using service account key
run: |
echo "${{ secrets.GCLOUD_SK2 }}" > gcloud-service-key.json
gcloud auth activate-service-account --key-file=gcloud-service-key.json
- name: set image and restart Kubernetes deployment
run: |
gcloud container clusters get-credentials ld-cluster-1 --region=us-central1
kubectl set image deployment/ld-deployment2 test-image=docker.io/lukehaz/test-image:latest
kubectl rollout restart deployment/ld-deployment2