-
Notifications
You must be signed in to change notification settings - Fork 9
103 lines (100 loc) · 4.32 KB
/
merge.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
# SPDX-License-Identifier: Apache-2.0
# Copyright Contributors to the ODPi Egeria project.
---
name: "Merge"
# Trigger after code is merged. only on main repo
# - does not run on modification (may be just text)
on:
push:
branches: [main, release-*, feature-*]
# Also allow for manual invocation for testing
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: "Merge"
env:
RELEASE_VERSION: 3.12-SNAPSHOT
steps:
- uses: actions/checkout@v3
name: Checkout source
# Only for a merge into this repo - not a fork
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "11"
- uses: gradle/wrapper-validation-action@v1
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
# Only for a merge into this repo - not a fork, and just for the main branch
- name: Build (Publish snapshots to maven central)
if: ${{ github.repository == 'odpi/egeria-connector-sas-viya' && github.ref == 'refs/heads/main'}}
# TODO: Need to extend build to make use of snapshot repo for publishing
run: ./gradlew publish
# Import secrets needed for code signing and distribution
env:
OSSRH_GPG_KEYID: ${{ secrets.OSSRH_GPG_KEYID }}
OSSRH_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }}
OSSRH_GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
# In other cases just build but don't publish
- name: Build (no snapshots)
if: ${{ github.repository != 'odpi/egeria-connector-sas-viya' || github.ref != 'refs/heads/main'}}
run: ./gradlew build
# --
- name: Upload Connector
uses: actions/upload-artifact@v3
with:
name: Connector
path: build/libs/*.jar
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
if: ${{ github.event_name == 'push' && github.repository == 'odpi/egeria-connector-sas-viya' }}
- name: Login to container registry (Quay.io)
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_ACCESS_TOKEN }}
if: ${{ github.event_name == 'push' && github.repository == 'odpi/egeria-connector-sas-viya' }}
# For releases (ie not main)
- name: Build and push (not main merge)
if: github.ref != 'refs/heads/main'
id: docker_build_release
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name == 'push' && github.repository == 'odpi/egeria-connector-sas-viya' }}
tags: odpi/egeria-connector-sas-viya:${{env.RELEASE_VERSION}}, quay.io/odpi/egeria-connector-sas-viya:${{env.RELEASE_VERSION}}
build-args: version=${{ env.RELEASE_VERSION }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
# For main code stream
- name: Build and push (main merge)
if: github.ref == 'refs/heads/main'
id: docker_build_main
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name == 'push' && github.repository == 'odpi/egeria-connector-sas-viya' }}
tags: odpi/egeria-connector-sas-viya:${{ env.RELEASE_VERSION}}, odpi/egeria-connector-sas-viya:latest, quay.io/odpi/egeria-connector-sas-viya:${{ env.RELEASE_VERSION}}, quay.io/odpi/egeria-connector-sas-viya:latest
build-args: version=${{ env.RELEASE_VERSION }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
- name: Image digest (release)
if: github.ref != 'refs/heads/main'
run: echo ${{ steps.docker_build_release.outputs.digest }}
- name: Image digest (main)
if: github.ref == 'refs/heads/main'
run: echo ${{ steps.docker_build_main.outputs.digest }}