try using method found in docs #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 with Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCLOUD_SK2 }} | |
- name: set up cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Use gcloud CLI | |
run: gcloud info | |
- 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 |