Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/queue-service-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ permissions:

jobs:
build-and-test:
name: Build and Test queue-service
runs-on: ubuntu-latest

steps:
Expand All @@ -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

Expand All @@ -60,4 +61,4 @@ jobs:
path: |
build/reports/tests/test/
build/reports/problems/
retention-days: 3
retention-days: 3
72 changes: 72 additions & 0 deletions .github/workflows/queue-service-deploy.yml
Original file line number Diff line number Diff line change
@@ -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.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --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
Loading