-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (44 loc) · 1.53 KB
/
main.yaml
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
54
name: Semantic-Version
on:
push:
branches:
#- main
- feat/issue/1
pull_request:
branches: [ main ]
env:
REPO_USER: 'jpradoar'
REPO_APP: 'ga-semanticversion'
BUILD_CONTEXT: './'
jobs:
Semantic-Version:
runs-on: ubuntu-latest
steps:
- name: Checkout del repositorio
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: jpradoar
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Show last version of docker-hub image
id: get_last_version
run: |
LastVersion=$(curl -s "https://hub.docker.com/v2/repositories/${{ env.REPO_USER }}/${{ env.REPO_APP }}/tags/?page_size=2" | jq -r '.results[].name'|sort -M|grep -v latest|tail -1)
echo "LAST_VERSION=$LastVersion " >> "$GITHUB_OUTPUT"
- name: Generate new version with local file
id: nversion
uses: jpradoar/[email protected]
with:
COMMIT_MSG: ${{ github.event.head_commit.message }}
VERSION: ${{ steps.get_last_version.outputs.LAST_VERSION }}
- name: Show new version
run: echo "New version ${{ steps.nversion.outputs.NEW_VERSION }}"
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ${{ env.BUILD_CONTEXT }}
push: true
tags: jpradoar/${{ env.REPO_APP }}:${{ steps.nversion.outputs.NEW_VERSION }}