|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "production" |
| 7 | + paths-ignore: |
| 8 | + - '.gitignore' |
| 9 | + - 'CODEOWNERS' |
| 10 | + - 'LICENSE' |
| 11 | + - '*.md' |
| 12 | + - '*.adoc' |
| 13 | + - '*.txt' |
| 14 | + - '.all-contributorsrc' |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: deployment |
| 18 | + cancel-in-progress: false |
| 19 | + |
| 20 | +jobs: |
| 21 | + deploy: |
| 22 | + |
| 23 | + # if: github.repository == 'hibernate/hibernate-jira-sync' |
| 24 | + |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up JDK 21 |
| 31 | + uses: actions/setup-java@v2 |
| 32 | + with: |
| 33 | + distribution: temurin |
| 34 | + java-version: 21 |
| 35 | + |
| 36 | + - name: Log in to OpenShift |
| 37 | + uses: redhat-actions/oc-login@v1 |
| 38 | + with: |
| 39 | + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_INFRA_PROD }} |
| 40 | + openshift_token: ${{ secrets.OPENSHIFT_TOKEN_INFRA_PROD }} |
| 41 | + namespace: ${{ secrets.OPENSHIFT_NAMESPACE_INFRA_PROD }} |
| 42 | + |
| 43 | + - name: Create ImageStream |
| 44 | + run: | |
| 45 | + oc create imagestream hibernate-jira-sync || true |
| 46 | + # https://docs.openshift.com/container-platform/4.14/openshift_images/using-imagestreams-with-kube-resources.html |
| 47 | + oc set image-lookup hibernate-jira-sync |
| 48 | +
|
| 49 | + - name: Retrieve OpenShift Container Registry URL |
| 50 | + id: oc-registry |
| 51 | + run: | |
| 52 | + echo -n "OC_REGISTRY_URL=" >> "$GITHUB_OUTPUT" |
| 53 | + oc registry info >> "$GITHUB_OUTPUT" |
| 54 | + - name: Log in to OpenShift Container Registry |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ${{ steps.oc-registry.outputs.OC_REGISTRY_URL }} |
| 58 | + username: ignored |
| 59 | + password: ${{ secrets.OPENSHIFT_TOKEN_INFRA_PROD }} |
| 60 | + # Helm in particular needs semantic versions |
| 61 | + # See https://github.com/helm/helm/issues/9342#issuecomment-775269042 |
| 62 | + # See the parts about pre-release versions in https://semver.org/#semantic-versioning-specification-semver |
| 63 | + # Ideally we should use a "+" before the SHA, but that won't work with Quarkus |
| 64 | + # See https://github.com/quarkusio/quarkus/blob/da1a782e04b01b2e165d65474163050d497340c1/extensions/container-image/spi/src/main/java/io/quarkus/container/spi/ImageReference.java#L60 |
| 65 | + - name: Generate app version |
| 66 | + id: app-version |
| 67 | + run: | |
| 68 | + echo "VALUE=1.0.0-$(date -u '+%Y%m%d%H%M%S')-${{ github.sha }}" >> $GITHUB_OUTPUT |
| 69 | +
|
| 70 | + - name: Build and push app container image |
| 71 | + run: | |
| 72 | + ./mvnw clean package \ |
| 73 | + -Drevision="${{ steps.app-version.outputs.value }}" \ |
| 74 | + -Dquarkus.container-image.build=true \ |
| 75 | + -Dquarkus.container-image.push=true \ |
| 76 | + -Dquarkus.container-image.registry="$(oc registry info)" \ |
| 77 | + -Dquarkus.container-image.group="$(oc project --short)" |
0 commit comments