-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.36 KB
/
Copy pathpackaging.yml
File metadata and controls
53 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Publish Package to GHCR
on:
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-and-publish:
name: Build and Push Docker Image
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
# 1. Configurar Java
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
# 2. Compilar el proyecto para generar el .jar
- name: Build with Maven
run: mvn clean package -DskipTests -P docker -f pom.xml
# 3. Normalizar el nombre del repositorio para Docker
- name: Normalize repository name
run: |
echo "REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# 4. Autenticación en GHCR
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 5. Construir y empujar la imagen Docker
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ env.REPO_LOWER }}:latest