From 6f320b1ba093954e8670eb72e4db0f16d9615c46 Mon Sep 17 00:00:00 2001 From: miguel-merlin Date: Thu, 21 Nov 2024 01:25:49 -0500 Subject: [PATCH] added gh actions to submit docker image --- .github/workflows/build.yaml | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/docker.yaml | 36 ++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..b0875cd --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,45 @@ +name: Build verification +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v3 + - name: Setup Docker and docker-compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + - name: Start postgres with docker-compose + run: docker-compose up -d + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + - name: Set up Maven + uses: stCarolas/setup-maven@v4 + with: + maven-version: '3.8.6' + - name: Build with Maven + run: mvn clean install + + dependency-submission: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + - name: Generate and submit dependecy graph + uses: advanced-security/maven-dependency-submission-action@v4 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..0262811 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,36 @@ +name: Build and publish Docker image +on: + push: + branches: ["main"] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + - name: Set up Maven + uses: stCarolas/setup-maven@v4 + with: + maven-version: '3.8.6' + - name: Build with maven + run: mvn clean package -DskipTests + - name: Login to Github container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + ghcr.io/stevensblueprint/orservice:${{ github.sha }} + ghcr.io/stevensblueprint/orservice:latest