Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(task-nr): rename job #1

Merged
merged 19 commits into from
Feb 23, 2024
49 changes: 33 additions & 16 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,39 @@ concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
TAG_VERSION: >-
${{
github.event_name == 'published' &&
github.event.release.tag_name
||
github.sha
}}

jobs:
set-envs:
runs-on: ubuntu-latest
steps:
- name: set tag version
run: |
if [ ${{ github.event_name }} == 'published' ]; then
echo "export TAG_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
else
echo "export TAG_VERSION=latest" >> $GITHUB_ENV
fi
# prepare:
# runs-on: ubuntu-latest
# steps:
# - name: Set tag version
# shell: bash
# run: |
# if [[ ${{ github.event_name }} == 'published' ]]; then
# echo "TAG_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
# else
# echo "TAG_VERSION=latest" >> $GITHUB_ENV
# fi
# echo "$TAG_VERSION"
build:
runs-on: ubuntu-latest
# needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
distribution: 'adopt'
java-version: '17'
- name: Compile
run: |
echo "Compiling the code"
Expand All @@ -45,23 +57,28 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v3
with:
images: ${{ github.event.repository.name }}:${{ env.TAG_VERSION }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
file: Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:$TAG_VERSION
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:${{ env.TAG_VERSION }}
deploy:
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) ||
(github.event_name == 'release' && github.event.action == 'published')
runs-on: ubuntu-latest
# needs: [prepare, build]
needs: build
steps:
- name: Deploy
run: |
echo "Deploying the app using ${{ github.event.repository.name }}:$TAG_VERSION image"
echo "Deploying the app using ${{ github.event.repository.name }}:${{ env.TAG_VERSION }} image"
3 changes: 1 addition & 2 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ on:
- synchronize

jobs:
main:
name: Validate PR title
validate-pr-title:
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
Expand Down
Loading