This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
chore: prisma problema #9
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: Docker Image CI | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
permissions: | |
contents: write # Permissão necessária para criar uma release | |
packages: write | |
issues: write | |
pull-requests: write | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22.x' | |
- name: Install pnpm, NestJS CLI, and Prisma CLI | |
run: npm install -g pnpm @nestjs/cli prisma | |
- name: Install dependencies | |
run: pnpm install | |
- name: Generate Prisma Client | |
run: pnpm prisma generate | |
- name: Build the project | |
run: pnpm run build | |
- name: Get latest version from Docker Hub excluding 'latest' | |
id: docker_version | |
run: | | |
TAGS_JSON=$(curl -s 'https://hub.docker.com/v2/repositories/softagon/eduprimecore/tags/') | |
LATEST_VERSION=$(echo $TAGS_JSON | jq -r '.results[].name | select(. != "latest")' | sort -V | tail -n1) | |
NEW_VERSION=$(echo $LATEST_VERSION | awk -F. '{print $1 "." $2 "." $3+1}') | |
echo "Latest version is $LATEST_VERSION" | |
echo "New version is $NEW_VERSION" | |
echo "version=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
softagon/eduprimecore:latest | |
softagon/eduprimecore:${{ env.version }} | |
- name: Get commit message | |
id: get_commit_message | |
run: echo "COMMIT_MESSAGE=$(git log -1 --pretty=%B)" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
if: ${{ success() }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.version }} | |
release_name: Release ${{ env.version }} | |
body: | | |
## Changes | |
- Docker image version ${{ env.version }} released. | |
- Commit message: ${{ env.COMMIT_MESSAGE }} | |
draft: false | |
prerelease: false |