main branch merge 대작전 (#129) #14
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: Front_CI_CD_For_GKE | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
if: github.repository == 'PhantomOfLINUX/POL_Front' | |
steps: | |
- name: git code checkout | |
uses: actions/checkout@v3 | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
**/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Make env file | |
run: | | |
echo "${{ secrets.ENV_PROPERTIES }}" > ".env" | |
cat .env | |
- name: docker setup | |
uses: docker/setup-buildx-action@v3 | |
- name: docker login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_ORGNIZATIONS }}/pol-front:${{ github.sha }} | |
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_ORGNIZATIONS }}/pol-front:cache | |
cache-to: type=inline | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GKE_SA_KEY }} | |
- name: Setup Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Install gke-gcloud-auth-plugin | |
run: gcloud components install gke-gcloud-auth-plugin | |
- name: Configure Docker for GKE | |
run: gcloud auth configure-docker --quiet | |
- name: Get GKE credentials | |
run: | | |
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER }} --zone ${{ secrets.GKE_ZONE }} --project ${{ secrets.GKE_PROJECT }} | |
- name: Deploy to GKE | |
run: | | |
kubectl set image deployment/pol-front pol-front=polhub/pol-front:${{ github.sha }} |