This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
fix: try to fix workflow #3
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'] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22.x' | |
- name: Install pnpm and NestJS CLI | |
run: npm install -g pnpm @nestjs/cli | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build the project | |
run: pnpm run build | |
- name: Get latest version from Docker Hub excluding 'latest' | |
id: docker_version | |
run: | | |
# Obter todas as tags do repositório | |
TAGS_JSON=$(curl -s 'https://hub.docker.com/v2/repositories/softagon/eduprimecore/tags/') | |
# Filtrar e encontrar a última versão, ignorando a tag 'latest' | |
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: Create GitHub Release | |
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. | |
draft: false | |
prerelease: false |