Add release
pipeline
#1
Workflow file for this run
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: Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
service: [ cat-fact-service ] | |
steps: | |
- name: Git Checkout | |
if: github.event_name != 'pull_request_target' | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
# Do not trigger a checkout when opening PRs from a fork (helps avoid | |
# "pwnn request". See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target ) | |
with: | |
fetch-depth: 0 | |
- name: Install Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
#Instead of manually configure caching of gradle, use an action which is provided. Details here: https://github.com/actions/setup-java | |
cache: gradle | |
- name: Get the version | |
id: version | |
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) | |
- name: Log tag version | |
run: echo "The version is ${{ steps.version.outputs.VERSION }}" | |
- name: Gradle Test | |
if: steps.changes.outputs.source_code == 'true' | |
id: tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew build | |
- name: Build Docker Image | |
if: steps.changes.outputs.source_code == 'true' | |
id: container | |
run: | | |
docker build --file ./Dockerfile --tag ${{ matrix.service }}:latest --tag:${{ matrix.service }}:${{ steps.version.outputs.VERSION }} . | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Publish Docker Image | |
run: | | |
docker push ghcr.io/ForkingGeniuses/${{ matrix.service }}:latest |