fix: main 브랜치 Container 실행 #4
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-containerize | |
on: | |
push: | |
branches: | |
- prod | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
JWT_ISSUER: ${{ secrets.JWT_ISSUER }} | |
JWT_ACCESS_KEY: ${{ secrets.JWT_ACCESS_KEY }} | |
JWT_REFRESH_KEY: ${{ secrets.JWT_REFRESH_KEY }} | |
jobs: | |
app-build-test-container-build-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Setup Java JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- run: | |
chmod +x gradlew && | |
./gradlew build | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker images | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
needs: app-build-test-container-build-push | |
runs-on: self-hosted | |
steps: | |
- name: Pull Image from GitHub Container Registry | |
run: sudo docker pull ghcr.io/limvik/budget-management-service:prod | |
- name: Delete old container | |
run: sudo docker rm -f econome-app | |
- name: Create .env file | |
run: echo "${{ secrets.ENV_FILE }}" > .env | |
- name: Run container | |
run: sudo docker run -d --env-file .env -p 80:9001 --name econome-app ghcr.io/limvik/budget-management-service:prod |