diff --git a/ci/android.yml b/ci/android.yml index 6954a61..4bbc689 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: 'adopt' + - 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..655a94c 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: 'adopt' - name: Build with Ant run: ant -noinput -buildfile build.xml diff --git a/ci/gradle-publish.yml b/ci/gradle-publish.yml index cec487e..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#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 @@ -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: '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 4550f58..6e7e922 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: '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 fb1c7ee..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#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 @@ -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: '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 @@ -27,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 }} diff --git a/ci/maven.yml b/ci/maven.yml index a46556a..923425b 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: 'adopt' - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/ci/openshift.yml b/ci/openshift.yml index 8a4875d..b9bcd0b 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 @@ -66,7 +67,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 +117,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 +131,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 +155,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 +173,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 }} 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 diff --git a/ci/scala.yml b/ci/scala.yml index 96bfc70..4a3c112 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: 'adopt' - name: Run tests run: sbt test