Skip to content

CI pipeline init

CI pipeline init #3

Workflow file for this run

name: Continuous Integration
on:
pull_request: { branches: [ "main" ] }
push:
branches: [ "main" ]
tags: [ "*" ]
jobs:
build:
name: "Build Image"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- id: generate-image-tag
name: Generate Image Tag
env:
ref_name: "${{ github.ref_name }}"
head_ref: "${{ github.head_ref }}"
run: |
head_ref="${head_ref/\//-}"
ref_name="${head_ref:-${ref_name/main/latest}}"
echo "::set-output name=imageTag::${ref_name#v}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Build with Maven
run: mvn clean install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./api-gateway
file: ./api-gateway/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.generate-image-tag.outputs.imageTag }}
ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.sha || github.sha }}