From ecb2bf74c050ba4a1768d60846d048953d3a9c29 Mon Sep 17 00:00:00 2001 From: kjp0411 <98109773+kjp0411@users.noreply.github.com> Date: Mon, 18 May 2026 17:45:03 +0900 Subject: [PATCH 1/2] feat: add CI/CD workflow for queue-service --- .github/workflows/queue-service-ci.yml | 11 ++-- .github/workflows/queue-service-deploy.yml | 72 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/queue-service-deploy.yml diff --git a/.github/workflows/queue-service-ci.yml b/.github/workflows/queue-service-ci.yml index ac69e06..b32dd51 100644 --- a/.github/workflows/queue-service-ci.yml +++ b/.github/workflows/queue-service-ci.yml @@ -21,6 +21,7 @@ permissions: jobs: build-and-test: + name: Build and Test queue-service runs-on: ubuntu-latest steps: @@ -34,13 +35,13 @@ jobs: java-version: 17 cache: gradle - - name: Grant execute permission - run: chmod +x gradlew + - name: Grant execute permission for Gradle wrapper + run: chmod +x ./gradlew - name: Run tests env: - GPR_USER: ${{ github.actor }} - GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPR_USER: ${{ secrets.GPR_USER }} + GPR_TOKEN: ${{ secrets.GPR_TOKEN }} QUEUE_TOKEN_SECRET: ${{ secrets.QUEUE_TOKEN_SECRET }} run: ./gradlew clean test @@ -60,4 +61,4 @@ jobs: path: | build/reports/tests/test/ build/reports/problems/ - retention-days: 3 \ No newline at end of file + retention-days: 3 diff --git a/.github/workflows/queue-service-deploy.yml b/.github/workflows/queue-service-deploy.yml new file mode 100644 index 0000000..61d13a4 --- /dev/null +++ b/.github/workflows/queue-service-deploy.yml @@ -0,0 +1,72 @@ +name: Queue Service CD + +on: + push: + branches: + - main + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: 3s-ticketing/queue-service + IMAGE_TAG: main-latest + +jobs: + build-and-push: + name: Build and Push queue-service image + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: gradle + + - name: Grant execute permission for Gradle wrapper + run: chmod +x ./gradlew + + - name: Run tests + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_TOKEN: ${{ secrets.GPR_TOKEN }} + QUEUE_TOKEN_SECRET: ${{ secrets.QUEUE_TOKEN_SECRET }} + run: ./gradlew clean test + + - name: Log in to GitHub Container Registry + run: echo "${{ secrets.GPR_TOKEN }}" | docker login ghcr.io -u ${{ secrets.GPR_USER }} --password-stdin + + - name: Build Docker image + run: | + docker build \ + --build-arg GPR_USER=${{ secrets.GPR_USER }} \ + --build-arg GPR_TOKEN=${{ secrets.GPR_TOKEN }} \ + -t $REGISTRY/$IMAGE_NAME:$IMAGE_TAG \ + -t $REGISTRY/$IMAGE_NAME:${{ github.sha }} \ + . + + - name: Push Docker image + run: | + docker push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG + docker push $REGISTRY/$IMAGE_NAME:${{ github.sha }} + + - name: Deploy queue-service to EC2 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + echo "${{ secrets.GPR_TOKEN }}" | docker login ghcr.io -u ${{ secrets.GPR_USER }} --password-stdin + cd ~/deploy/ticketing/ticketing-system + docker compose -f docker-compose.app.yml pull queue-service + docker compose -f docker-compose.app.yml up -d --no-deps --force-recreate queue-service + docker ps --filter "name=ticketing-queue-service" + docker image prune -f From 1a0c111a2daa9b1eebe1d5c4278fc33277fea4a9 Mon Sep 17 00:00:00 2001 From: kjp0411 <98109773+kjp0411@users.noreply.github.com> Date: Mon, 18 May 2026 22:02:46 +0900 Subject: [PATCH 2/2] fix: use GITHUB_TOKEN for GHCR image push --- .github/workflows/queue-service-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/queue-service-deploy.yml b/.github/workflows/queue-service-deploy.yml index 61d13a4..0b76c6e 100644 --- a/.github/workflows/queue-service-deploy.yml +++ b/.github/workflows/queue-service-deploy.yml @@ -41,7 +41,7 @@ jobs: run: ./gradlew clean test - name: Log in to GitHub Container Registry - run: echo "${{ secrets.GPR_TOKEN }}" | docker login ghcr.io -u ${{ secrets.GPR_USER }} --password-stdin + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Build Docker image run: |