-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (97 loc) · 3.51 KB
/
api.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build & Deploy Spring Boot API [api]
on:
push:
branches: [ "main" ]
paths:
- 'api/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: arnaublanch/setlist-to-playlist-api
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
outputs:
IMAGE_VERSION: ${{ steps.tag_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install cosign
uses: sigstore/cosign-installer@df6c89e679716101b2628c1c3cd997f7626f27b8 #v2.8.1
with:
cosign-release: 'v1.13.1'
- name: Setup Docker buildx
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
tag_prefix: api-v
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ steps.tag_version.outputs.new_version }}
type=sha,enable=false
flavor: |
latest=true
- name: Gradle Build
run: |
cd api
gradle build
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5
with:
context: api
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
release:
runs-on: ubuntu-latest
needs: build
environment: Production
steps:
- name: Deploy to Dokku
uses: dokku/github-action@master
with:
git_remote_url: 'ssh://dokku@${{ secrets.DOKKU_HOST }}:22/${{ secrets.API_APP_NAME }}'
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.IMAGE_VERSION }}