Skip to content

changed to ?

changed to ? #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 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: setup gke-gcloud-auth-plugin
uses: simenandre/setup-gke-gcloud-auth-plugin@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
cluster_name: "ld-cluster-1"
cluster_region: "us-central1"
- name: authenticate plugin with Google Cloud
run: gke-gcloud-auth-plugin authenticate
- 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