fix: 환경변수 누락된 부분 수정 (#66) #7
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: cd for click-service | |
on: | |
push: | |
branches: [ "main" ] | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
DOCKER_REPO: ${{ secrets.DOCKER_REPO }} | |
REGION: ${{ secrets.REGION }} | |
WORKSTATION_IMAGE: click-service | |
VERSION: '1.0.0' | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
working-directory: ./click-service | |
steps: | |
- name: Check out Repository | |
uses: actions/checkout@v3 | |
- name: Set Kubernetes Yaml | |
run : | | |
envsubst < ./resources.yaml > ./resources.yaml | |
env: | |
spec.template.spec.containers.image: ${{env.REGION}}-docker.pkg.dev/${{env.PROJECT_ID}}/${{env.DOCKER_REPO}}/${{env.WORKSTATION_IMAGE}} | |
- name: Set Application Yml | |
run : | | |
envsubst < ./src/main/resources/application-prod.yml > ./src/main/resources/application-prod.yml | |
env: | |
spring.data.redis.host: ${{secrets.REDIS_HOST}} | |
spring.data.redis.port: ${{secrets.REDIS_PORT}} | |
spring.datasource.url: ${{secrets.DB_URL}} | |
spring.datasource.username: ${{secrets.DB_USERNAME}} | |
spring.datasource.password: ${{secrets.DB_PASSWORD}} | |
- name: Set up google auth | |
id: 'auth' | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCE_SA_KEY }} | |
- id: get-credentials | |
uses: google-github-actions/get-gke-credentials@v1 | |
with: | |
cluster_name: autopilot-cluster-1 | |
location: ${{env.REGION}} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ env.PROJECT_ID }} | |
- name: Set up Java version | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17' | |
- name: Run tests | |
run: ../gradlew test | |
- name: Docker Build | |
if: success() | |
run: ../gradlew docker | |
- name: Docker tag | |
run: docker tag click-me-${{env.WORKSTATION_IMAGE}}:${{env.VERSION}} ${{env.image}} | |
- name: Docker Push | |
run: docker push ${{env.image}} | |
- name: Deploy | |
run: kubectl apply -f ./resources.yaml | |