From ce889525cc7fd3a56964e5873804bf178349be53 Mon Sep 17 00:00:00 2001 From: AlyonaSviridenko Date: Tue, 2 Mar 2021 18:43:44 +0300 Subject: [PATCH 1/6] updated workflows with new version of setup-java --- ci/android.yml | 8 +++++--- ci/ant.yml | 7 ++++--- ci/gradle-publish.yml | 9 +++++---- ci/gradle.yml | 7 ++++--- ci/maven-publish.yml | 9 +++++---- ci/maven.yml | 7 ++++--- ci/scala.yml | 7 ++++--- 7 files changed, 31 insertions(+), 23 deletions(-) diff --git a/ci/android.yml b/ci/android.yml index 6954a61..3edebb5 100644 --- a/ci/android.yml +++ b/ci/android.yml @@ -13,10 +13,12 @@ jobs: steps: - uses: actions/checkout@v2 - - name: set up JDK 1.8 - uses: actions/setup-java@v1 + - name: set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' + - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/ci/ant.yml b/ci/ant.yml index 28fe6d0..8b8a5ba 100644 --- a/ci/ant.yml +++ b/ci/ant.yml @@ -16,9 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' - name: Build with Ant run: ant -noinput -buildfile build.xml diff --git a/ci/gradle-publish.yml b/ci/gradle-publish.yml index cec487e..2faa3aa 100644 --- a/ci/gradle-publish.yml +++ b/ci/gradle-publish.yml @@ -1,5 +1,5 @@ # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java#publishing-using-gradle +# For more information see: https://github.com/actions/setup-java/docs/advanced-usage.md#Publishing-using-gradle name: Gradle Package @@ -14,10 +14,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/ci/gradle.yml b/ci/gradle.yml index 4550f58..6ffdc6a 100644 --- a/ci/gradle.yml +++ b/ci/gradle.yml @@ -16,10 +16,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/ci/maven-publish.yml b/ci/maven-publish.yml index fb1c7ee..831b54b 100644 --- a/ci/maven-publish.yml +++ b/ci/maven-publish.yml @@ -1,5 +1,5 @@ # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path +# For more information see: https://github.com/actions/setup-java/docs/advanced-usage.md#apache-maven-with-a-settings-path name: Maven Package @@ -14,10 +14,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/ci/maven.yml b/ci/maven.yml index a46556a..005184b 100644 --- a/ci/maven.yml +++ b/ci/maven.yml @@ -16,9 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/ci/scala.yml b/ci/scala.yml index 96bfc70..e650d8a 100644 --- a/ci/scala.yml +++ b/ci/scala.yml @@ -13,9 +13,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 11 + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '11' + distribution: 'adoptium' - name: Run tests run: sbt test From f42ac9c022d58205b5936aa59a174f00962a7070 Mon Sep 17 00:00:00 2001 From: AlyonaSviridenko Date: Thu, 11 Mar 2021 12:56:09 +0300 Subject: [PATCH 2/6] renamed adoptium to adopt --- ci/android.yml | 2 +- ci/ant.yml | 2 +- ci/gradle-publish.yml | 2 +- ci/gradle.yml | 2 +- ci/maven-publish.yml | 2 +- ci/maven.yml | 2 +- ci/scala.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ci/android.yml b/ci/android.yml index 3edebb5..4bbc689 100644 --- a/ci/android.yml +++ b/ci/android.yml @@ -17,7 +17,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/ci/ant.yml b/ci/ant.yml index 8b8a5ba..655a94c 100644 --- a/ci/ant.yml +++ b/ci/ant.yml @@ -20,6 +20,6 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' - name: Build with Ant run: ant -noinput -buildfile build.xml diff --git a/ci/gradle-publish.yml b/ci/gradle-publish.yml index 2faa3aa..e69fc09 100644 --- a/ci/gradle-publish.yml +++ b/ci/gradle-publish.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/ci/gradle.yml b/ci/gradle.yml index 6ffdc6a..6e7e922 100644 --- a/ci/gradle.yml +++ b/ci/gradle.yml @@ -20,7 +20,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/ci/maven-publish.yml b/ci/maven-publish.yml index 831b54b..6538c9e 100644 --- a/ci/maven-publish.yml +++ b/ci/maven-publish.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/ci/maven.yml b/ci/maven.yml index 005184b..923425b 100644 --- a/ci/maven.yml +++ b/ci/maven.yml @@ -20,6 +20,6 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/ci/scala.yml b/ci/scala.yml index e650d8a..4a3c112 100644 --- a/ci/scala.yml +++ b/ci/scala.yml @@ -17,6 +17,6 @@ jobs: uses: actions/setup-java@v2 with: java-version: '11' - distribution: 'adoptium' + distribution: 'adopt' - name: Run tests run: sbt test From 019de53cfb24ce35e5b64d47aca87779a47de011 Mon Sep 17 00:00:00 2001 From: Sergey Yakimov Date: Thu, 18 Mar 2021 15:28:14 +0200 Subject: [PATCH 3/6] Remove the deprecated "--no-suggest" option from the Composer install step --- ci/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/php.yml b/ci/php.yml index e1dceef..6acfdd1 100644 --- a/ci/php.yml +++ b/ci/php.yml @@ -27,7 +27,7 @@ jobs: ${{ runner.os }}-php- - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest + run: composer install --prefer-dist --no-progress # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" # Docs: https://getcomposer.org/doc/articles/scripts.md From 7c8569ab2bcbca327d9745f7f77ad89918d68585 Mon Sep 17 00:00:00 2001 From: Divyanshu Agrawal Date: Tue, 9 Mar 2021 19:32:22 +0530 Subject: [PATCH 4/6] Modify openshift workflow with v2 version of actions and add oc-new-app (#1) * Modify openshift workflow with v2 version of actions and add oc-new-app Signed-off-by: divyansh42 --- ci/openshift.yml | 84 +++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/ci/openshift.yml b/ci/openshift.yml index 8a4875d..e25afef 100644 --- a/ci/openshift.yml +++ b/ci/openshift.yml @@ -27,6 +27,7 @@ # For a more sophisticated example, see https://github.com/redhat-actions/spring-petclinic/blob/main/.github/workflows/petclinic-sample.yaml # Also see our GitHub organization, https://github.com/redhat-actions/ +# ▶️ See a video of how to set up this workflow at https://www.youtube.com/watch?v=6hgBO-1pKho name: OpenShift @@ -52,6 +53,7 @@ env: # If you wish to manually provide the APP_NAME and TAG, set them here, otherwise they will be auto-detected. APP_NAME: "" + TAG: "" on: @@ -66,7 +68,42 @@ jobs: runs-on: ubuntu-20.04 environment: production + outputs: + ROUTE: ${{ steps.deploy-and-expose.outputs.route }} + SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} + steps: + - name: Check if secrets exists + uses: actions/github-script@v3 + with: + script: | + const secrets = { + REGISTRY_PASSWORD: `${{ secrets.REGISTRY_PASSWORD }}`, + OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, + OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, + }; + + const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { + if (value.length === 0) { + core.warning(`Secret "${name}" is not set`); + return true; + } + core.info(` ✔️ Secret "${name}" is set`); + return false; + + }); + + if (missingSecrets.length > 0) { + core.setFailed(`❌ At least one required secret is not set in the repository. \n` + + "You can add it using:\n" + + "Github UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + + "Github CLI: https://cli.github.com/manual/gh_secret_set \n" + + "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); + } + else { + core.info(`✅ All the required secrets are set`); + } + - uses: actions/checkout@v2 - name: Determine app name @@ -81,12 +118,13 @@ jobs: # https://github.com/redhat-actions/buildah-build#readme - name: Build from Dockerfile - uses: redhat-actions/buildah-build@v1 + id: image-build + uses: redhat-actions/buildah-build@v2 with: image: ${{ env.APP_NAME }} - tag: ${{ env.TAG }} + tags: ${{ env.TAG }} # If you don't have a dockerfile, see: - # https://github.com/redhat-actions/buildah-build#building-from-scratch + # https://github.com/redhat-actions/buildah-build#scratch-build-inputs # Otherwise, point this to your Dockerfile relative to the repository root. dockerfiles: | ./Dockerfile @@ -94,10 +132,10 @@ jobs: # https://github.com/redhat-actions/push-to-registry#readme - name: Push to registry id: push-to-registry - uses: redhat-actions/push-to-registry@v1 + uses: redhat-actions/push-to-registry@v2 with: - image: ${{ env.APP_NAME }} - tag: ${{ env.TAG }} + image: ${{ steps.image-build.outputs.image }} + tags: ${{ steps.image-build.outputs.tags }} registry: ${{ env.REGISTRY }} username: ${{ env.REGISTRY_USER }} password: ${{ env.REGISTRY_PASSWORD }} @@ -118,30 +156,15 @@ jobs: namespace: ${{ env.OPENSHIFT_NAMESPACE }} # This step should create a deployment, service, and route to run your app and expose it to the internet. - # Feel free to replace this with 'oc apply', 'helm install', or however you like to deploy your app. + # https://github.com/redhat-actions/oc-new-app#readme - name: Create and expose app - run: | - export IMAGE="${{ steps.push-to-registry.outputs.registry-path }}" - export PORT=${{ env.APP_PORT }} - - export SELECTOR="app=${{ env.APP_NAME }}" - echo "SELECTOR=$SELECTOR" >> $GITHUB_ENV - - set -x - # Take down any old deployment - oc delete all --selector="$SELECTOR" - oc new-app --name $APP_NAME --docker-image="$IMAGE" - - # Make sure the app port is exposed - oc patch svc $APP_NAME -p "{ \"spec\": { \"ports\": [{ \"name\": \"$PORT-tcp\", \"port\": $PORT }] } }" - oc expose service $APP_NAME --port=$PORT - - oc get all --selector="$SELECTOR" - set +x - - export ROUTE="$(oc get route $APP_NAME -o jsonpath='{.spec.host}')" - echo "$APP_NAME is exposed at $ROUTE" - echo "ROUTE=$ROUTE" >> $GITHUB_ENV + id: deploy-and-expose + uses: redhat-actions/oc-new-app@v1 + with: + app_name: ${{ env.APP_NAME }} + image: ${{ steps.push-to-registry.outputs.registry-path }} + namespace: ${{ env.OPENSHIFT_NAMESPACE }} + port: ${{ env.APP_PORT }} - name: View application route run: | @@ -151,3 +174,6 @@ jobs: echo "===================================================================================" echo echo "Your app can be taken down with: \"oc delete all --selector='${{ env.SELECTOR }}'\"" + env: + ROUTE: ${{ steps.deploy-and-expose.outputs.route }} + SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} From c08e24c17b12e3bc9d346fa5aa745aa8c497fd23 Mon Sep 17 00:00:00 2001 From: divyansh42 Date: Wed, 24 Mar 2021 20:21:19 +0530 Subject: [PATCH 5/6] Resolve reviews Signed-off-by: divyansh42 --- ci/openshift.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ci/openshift.yml b/ci/openshift.yml index e25afef..b9bcd0b 100644 --- a/ci/openshift.yml +++ b/ci/openshift.yml @@ -53,7 +53,6 @@ env: # If you wish to manually provide the APP_NAME and TAG, set them here, otherwise they will be auto-detected. APP_NAME: "" - TAG: "" on: @@ -88,7 +87,7 @@ jobs: core.warning(`Secret "${name}" is not set`); return true; } - core.info(` ✔️ Secret "${name}" is set`); + core.info(`✔️ Secret "${name}" is set`); return false; }); @@ -96,14 +95,14 @@ jobs: if (missingSecrets.length > 0) { core.setFailed(`❌ At least one required secret is not set in the repository. \n` + "You can add it using:\n" + - "Github UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + - "Github CLI: https://cli.github.com/manual/gh_secret_set \n" + + "GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + + "GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); } else { core.info(`✅ All the required secrets are set`); } - + - uses: actions/checkout@v2 - name: Determine app name From 1f729c2f025d52b5407657a3fe8130bec1353717 Mon Sep 17 00:00:00 2001 From: Alena Sviridenko Date: Mon, 5 Apr 2021 17:44:33 +0300 Subject: [PATCH 6/6] Fixed docs path Co-authored-by: Konrad Pabjan --- ci/gradle-publish.yml | 2 +- ci/maven-publish.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/gradle-publish.yml b/ci/gradle-publish.yml index e69fc09..ef99e13 100644 --- a/ci/gradle-publish.yml +++ b/ci/gradle-publish.yml @@ -1,5 +1,5 @@ # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/docs/advanced-usage.md#Publishing-using-gradle +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle name: Gradle Package diff --git a/ci/maven-publish.yml b/ci/maven-publish.yml index 6538c9e..c3f4855 100644 --- a/ci/maven-publish.yml +++ b/ci/maven-publish.yml @@ -1,5 +1,5 @@ # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/docs/advanced-usage.md#apache-maven-with-a-settings-path +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path name: Maven Package @@ -28,4 +28,4 @@ jobs: - name: Publish to GitHub Packages Apache Maven run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file + GITHUB_TOKEN: ${{ github.token }}