forked from indexdata/mod-harvester-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (109 loc) · 4 KB
/
release-maven.yml
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
110
111
112
113
name: release-maven
# IMAGE_NAME: string; The name of the module.
# 'indexdata/mod-harvester-admin'
env:
FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com'
CONTAINER_REGISTRY: 'ghcr.io'
IMAGE_NAME: 'indexdata/mod-harvester-admin'
on:
push:
tags:
# - '[vV][0-9]+.[0-9]+.[0-9]+' # i.e. release tag only
- '[vV][0-9]+.[0-9]+.[0-9]+*' # i.e. allow snapshot tag
jobs:
release-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Gather some variables
run: |
echo "MODULE_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV
echo "MODULE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV
- name: Report dependencies that are snaphots
run: mvn dependency:list | { grep -i snapshot || true; }
- name: Do Maven build
run: mvn clean install
- name: Ensure built ModuleDescriptor
run: |
if test -f "$MOD_DESCRIPTOR"; then
echo "Found $MOD_DESCRIPTOR"
echo "MODULE_DESCRIPTOR=$MOD_DESCRIPTOR" >> $GITHUB_ENV
else
echo "Could not find $MOD_DESCRIPTOR"
exit 1
fi
env:
MOD_DESCRIPTOR: './target/ModuleDescriptor.json'
- name: Login ModuleDescriptor registry
id: login-md-registry
# uses: indiesdev/[email protected]
uses: cyberman54/[email protected]
with:
url: "${{ env.FOLIO_MD_REGISTRY }}/authn/login"
method: "POST"
accept: 201
timeout: 5000
retries: 3
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}"
}
body: |
{
"username": "${{ secrets.FOLIO_REGISTRY_USERNAME }}",
"password": "${{ secrets.FOLIO_REGISTRY_PASSWORD }}"
}
- name: Get the MD registry login token
run: |
echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.ACTOR }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.vendor=Index Data LLC
org.opencontainers.image.documentation=https://github.com/indexdata/localindices/tree/master/doc
- name: Build and publish Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Read ModuleDescriptor
id: moduleDescriptor
uses: juliangruber/read-file-action@v1
with:
path: ${{ env.MODULE_DESCRIPTOR }}
- name: Publish ModuleDescriptor to MD registry
id: result-md-registry
# uses: indiesdev/[email protected]
uses: cyberman54/[email protected]
with:
url: "${{ env.FOLIO_MD_REGISTRY }}/_/proxy/modules"
method: "POST"
accept: 201
timeout: 5000
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}",
"x-okapi-token": "${{ env.TOKEN_MD_REGISTRY }}"
}
body: ${{ steps.moduleDescriptor.outputs.content }}