mirror of https://github.com/jacekkow/keycloak-protocol-cas

Jacek Kowalski
2020-04-22 fd0b0f59812335633513d05f08264dddcdc909b7
Replace Travis CI build with GitHub actions
1 files deleted
2 files added
303 ■■■■ changed files
.github/workflows/release.yml 144 ●●●●● patch | view | raw | blame | history
.github/workflows/test.yml 109 ●●●●● patch | view | raw | blame | history
.travis.yml 50 ●●●●● patch | view | raw | blame | history
.github/workflows/release.yml
New file
@@ -0,0 +1,144 @@
on:
  push:
    tags:
      - '[0-9]+.*'
name: Release
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - id: checkout
        name: Checkout code
        uses: actions/checkout@v2
      - name: Install Java and Maven
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - id: vars
        name: Get project variables
        run: |
          echo -n "::set-output name=keycloakVersion::"
          mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=artifactId::"
          mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=projectName::"
          mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=projectVersion::"
          mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null
          echo
      - name: Build project
        run: |
          mvn -B test package
      - name: Upload artifact
        uses: actions/upload-artifact@v1
        with:
          name: jar
          path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar
    outputs:
      artifact_id: ${{ steps.vars.outputs.artifactId }}
      keycloak_version: ${{ steps.vars.outputs.keycloakVersion }}
      project_name: ${{ steps.vars.outputs.projectName }}
      project_version: ${{ steps.vars.outputs.projectVersion }}
  test:
    name: Test
    runs-on: ubuntu-latest
    needs: build
    services:
      keycloak:
        image: quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }}
        env:
          KEYCLOAK_USER: admin
          KEYCLOAK_PASSWORD: admin
        ports:
          - 8080:8080
        volumes:
          - '${{ github.workspace }}:/workspace'
    steps:
      - id: checkout
        name: Checkout code
        uses: actions/checkout@v2
      - id: download_artifact
        name: Download artifact
        uses: actions/download-artifact@v1
        with:
          name: jar
      - id: deploy
        name: Deploy artifact
        run: |
          CONTAINER="${{ job.services.keycloak.id }}"
          NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar"
          FILE="/opt/jboss/keycloak/standalone/deployments/${NAME}"
          docker cp "jar/${NAME}" "${CONTAINER}:/tmp/"
          docker exec -i "${CONTAINER}" /bin/bash <<EOF
            cp "/tmp/${NAME}" "${FILE}"
            for i in {1..60}; do
              echo -n .
              [ -f "${FILE}.deployed" ] && echo && echo "Deployment succeeded!" && exit 0
              [ -f "${FILE}.failed" ] && echo && echo "Deployment failed!" && exit 1
              sleep 1
            done
            echo && echo "Deployment timeout!" && exit 1
          EOF
      - id: configure_keycloak
        name: Configure Keycloak
        run: |
          CONTAINER="${{ job.services.keycloak.id }}"
          docker exec -i "${CONTAINER}" /bin/bash <<EOF
            /opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin
            /opt/jboss/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \
              -s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost
            /opt/jboss/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas
          EOF
      - id: run_tests
        name: Run tests
        run: |
          integrationTest/suite.sh
  release:
    name: Release
    runs-on: ubuntu-latest
    needs: [build, test]
    steps:
      - id: download_artifact
        name: Download artifact
        uses: actions/download-artifact@v1
        with:
          name: jar
      - id: create_release
        name: Create release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ needs.build.outputs.project_name }} ${{ needs.build.outputs.project_version }}
          draft: false
          prerelease: false
      - id: upload_release
        name: Upload release artifact
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: jar/${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar
          asset_name: ${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar
          asset_content_type: application/java-archive
.github/workflows/test.yml
New file
@@ -0,0 +1,109 @@
on:
  pull_request:
name: Test
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - id: checkout
        name: Checkout code
        uses: actions/checkout@v2
      - name: Install Java and Maven
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - id: vars
        name: Get project variables
        run: |
          echo -n "::set-output name=keycloakVersion::"
          mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=artifactId::"
          mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=projectName::"
          mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null
          echo
          echo -n "::set-output name=projectVersion::"
          mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null
          echo
      - name: Build project
        run: |
          mvn -B test package
      - name: Upload artifact
        uses: actions/upload-artifact@v1
        with:
          name: jar
          path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar
    outputs:
      artifact_id: ${{ steps.vars.outputs.artifactId }}
      keycloak_version: ${{ steps.vars.outputs.keycloakVersion }}
      project_name: ${{ steps.vars.outputs.projectName }}
      project_version: ${{ steps.vars.outputs.projectVersion }}
  test:
    name: Test
    runs-on: ubuntu-latest
    needs: build
    services:
      keycloak:
        image: quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }}
        env:
          KEYCLOAK_USER: admin
          KEYCLOAK_PASSWORD: admin
        ports:
          - 8080:8080
        volumes:
          - '${{ github.workspace }}:/workspace'
    steps:
      - id: checkout
        name: Checkout code
        uses: actions/checkout@v2
      - id: download_artifact
        name: Download artifact
        uses: actions/download-artifact@v1
        with:
          name: jar
      - id: deploy
        name: Deploy artifact
        run: |
          CONTAINER="${{ job.services.keycloak.id }}"
          NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar"
          FILE="/opt/jboss/keycloak/standalone/deployments/${NAME}"
          docker cp "jar/${NAME}" "${CONTAINER}:/tmp/"
          docker exec -i "${CONTAINER}" /bin/bash <<EOF
            cp "/tmp/${NAME}" "${FILE}"
            for i in {1..60}; do
              echo -n .
              [ -f "${FILE}.deployed" ] && echo && echo "Deployment succeeded!" && exit 0
              [ -f "${FILE}.failed" ] && echo && echo "Deployment failed!" && exit 1
              sleep 1
            done
            echo && echo "Deployment timeout!" && exit 1
          EOF
      - id: configure_keycloak
        name: Configure Keycloak
        run: |
          CONTAINER="${{ job.services.keycloak.id }}"
          docker exec -i "${CONTAINER}" /bin/bash <<EOF
            /opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin
            /opt/jboss/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \
              -s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost
            /opt/jboss/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas
          EOF
      - id: run_tests
        name: Run tests
        run: |
          integrationTest/suite.sh
.travis.yml
File was deleted