|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + branches: qa-framework-test |
| 8 | + |
| 9 | +jobs: |
| 10 | + deploy_to_github: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - uses: coursier/cache-action@v3 |
| 15 | + - name: Set up JDK |
| 16 | + uses: actions/setup-java@v1 |
| 17 | + with: |
| 18 | + java-version: 11 |
| 19 | + - name: Build artifacts |
| 20 | + run: | |
| 21 | + sbt 'project kafka' assembly |
| 22 | + sbt 'project kinesis' assembly |
| 23 | + sbt 'project nsq' assembly |
| 24 | + sbt 'project pubsub' assembly |
| 25 | + sbt 'project sqs' assembly |
| 26 | + sbt 'project stdout' assembly |
| 27 | + - name: Get current version |
| 28 | + id: ver |
| 29 | + run: | |
| 30 | + export PROJECT_VERSION=$(sbt "project core" version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') |
| 31 | + echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT |
| 32 | + - name: Create GitHub release and attach artifacts |
| 33 | + uses: softprops/action-gh-release@v1 |
| 34 | + with: |
| 35 | + draft: true |
| 36 | + prerelease: true |
| 37 | + name: ${{ steps.ver.outputs.project_version }} |
| 38 | + tag_name: ${{ steps.ver.outputs.project_version }} |
| 39 | + files: | |
| 40 | + kafka/target/scala-2.13/snowplow-stream-collector-kafka-${{ steps.ver.outputs.project_version }}.jar |
| 41 | + kinesis/target/scala-2.13/snowplow-stream-collector-kinesis-${{ steps.ver.outputs.project_version }}.jar |
| 42 | + nsq/target/scala-2.13/snowplow-stream-collector-nsq-${{ steps.ver.outputs.project_version }}.jar |
| 43 | + pubsub/target/scala-2.13/snowplow-stream-collector-google-pubsub-${{ steps.ver.outputs.project_version }}.jar |
| 44 | + sqs/target/scala-2.13/snowplow-stream-collector-sqs-${{ steps.ver.outputs.project_version }}.jar |
| 45 | + stdout/target/scala-2.13/snowplow-stream-collector-stdout-${{ steps.ver.outputs.project_version }}.jar |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + deploy_to_docker: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + strategy: |
| 52 | + matrix: |
| 53 | + platform: |
| 54 | + - kinesis |
| 55 | + - sqs |
| 56 | + - pubsub |
| 57 | + - kafka |
| 58 | + - nsq |
| 59 | + - stdout |
| 60 | + include: |
| 61 | + - suffix: "" |
| 62 | + - platform: kinesis |
| 63 | + run_snyk: ${{ !contains(github.ref, 'rc') }} |
| 64 | + - platform: pubsub |
| 65 | + run_snyk: ${{ !contains(github.ref, 'rc') }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v2 |
| 69 | + - uses: coursier/cache-action@v3 |
| 70 | + - name: Set up JDK |
| 71 | + uses: actions/setup-java@v1 |
| 72 | + with: |
| 73 | + java-version: 11 |
| 74 | + |
| 75 | + - name: Get current version |
| 76 | + id: ver |
| 77 | + run: | |
| 78 | + export PROJECT_VERSION=$(sbt "project core" version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') |
| 79 | + echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT |
| 80 | +
|
| 81 | + - name: Stage the Docker build |
| 82 | + run: sbt "project ${{ matrix.platform }}" docker:stage |
| 83 | + |
| 84 | + - name: Stage the Docker distroless build |
| 85 | + run: sbt "project ${{ matrix.platform }}Distroless" docker:stage |
| 86 | + |
| 87 | + - name: Docker metadata |
| 88 | + id: meta |
| 89 | + uses: docker/metadata-action@v3 |
| 90 | + with: |
| 91 | + images: snowplow/scala-stream-collector-${{ matrix.platform }}${{ matrix.suffix }} |
| 92 | + tags: | |
| 93 | + type=raw,value=latest,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} |
| 94 | + type=raw,value=latest-focal,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} |
| 95 | + type=raw,value=${{ steps.ver.outputs.project_version }} |
| 96 | + type=raw,value=${{ steps.ver.outputs.project_version }}-focal |
| 97 | + flavor: | |
| 98 | + latest=false |
| 99 | +
|
| 100 | + - name: Docker metadata distroless |
| 101 | + id: distroless-meta |
| 102 | + uses: docker/metadata-action@v3 |
| 103 | + with: |
| 104 | + images: snowplow/scala-stream-collector-${{ matrix.platform }}${{ matrix.suffix }} |
| 105 | + tags: | |
| 106 | + type=raw,value=latest-distroless,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} |
| 107 | + type=raw,value=${{ steps.ver.outputs.project_version }}-distroless |
| 108 | + flavor: | |
| 109 | + latest=false |
| 110 | +
|
| 111 | + - name: Set up QEMU |
| 112 | + uses: docker/setup-qemu-action@v1 |
| 113 | + |
| 114 | + - name: Set up Docker Buildx |
| 115 | + uses: docker/setup-buildx-action@v1 |
| 116 | + |
| 117 | + - name: Login to DockerHub |
| 118 | + uses: docker/login-action@v1 |
| 119 | + with: |
| 120 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 121 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 122 | + |
| 123 | + - name: Push image |
| 124 | + uses: docker/build-push-action@v2 |
| 125 | + with: |
| 126 | + context: ${{ matrix.platform }}/target/docker/stage |
| 127 | + file: ${{ matrix.platform }}/target/docker/stage/Dockerfile |
| 128 | + platforms: linux/amd64,linux/arm64/v8 |
| 129 | + tags: ${{ steps.meta.outputs.tags }} |
| 130 | + push: true |
| 131 | + - name: Push distroless image |
| 132 | + uses: docker/build-push-action@v2 |
| 133 | + with: |
| 134 | + context: distroless/${{ matrix.platform }}/target/docker/stage |
| 135 | + file: distroless/${{ matrix.platform }}/target/docker/stage/Dockerfile |
| 136 | + platforms: linux/amd64,linux/arm64/v8 |
| 137 | + tags: ${{ steps.distroless-meta.outputs.tags }} |
| 138 | + push: true |
| 139 | + |
| 140 | + # - name: Build local distroless image, which is needed to run Snyk |
| 141 | + # if: matrix.run_snyk |
| 142 | + # run: sbt "project ${{ matrix.platform }}Distroless" docker:publishLocal |
| 143 | + - name: Show local docker images |
| 144 | + run: docker images |
| 145 | + - name: Execute QA Framework tests |
| 146 | + uses: aurelien-baudet/workflow-dispatch@v2 |
| 147 | + with: |
| 148 | + workflow: test-component |
| 149 | + repo: snowplow-devops/qa-framework |
| 150 | + token: ${{ secrets.GLOBAL_QA_FRAMEWORK_PAT }} |
| 151 | + inputs: '{ "test_directory": "collector", "qa_collector_version": steps.ver.outputs.project_version }' |
| 152 | + # - name: Run Snyk to check for vulnerabilities |
| 153 | + # uses: snyk/actions/docker@master |
| 154 | + # if: matrix.run_snyk |
| 155 | + # with: |
| 156 | + # image: "snowplow/scala-stream-collector-${{ matrix.platform }}:${{ github.ref_name }}-distroless" |
| 157 | + # args: "--app-vulns --org=data-processing-new" |
| 158 | + # command: monitor |
| 159 | + # env: |
| 160 | + # SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} |
0 commit comments