|
5 | 5 | types: [prereleased, released] |
6 | 6 |
|
7 | 7 | jobs: |
| 8 | + build: |
| 9 | + name: Build integration for |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + goos: [ linux ] |
| 14 | + goarch: [ amd64, arm64, arm ] |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + - uses: actions/setup-go@v2 |
| 18 | + with: |
| 19 | + go-version: '1.16' |
| 20 | + - name: Build integration |
| 21 | + env: |
| 22 | + GOOS: ${{ matrix.goos }} |
| 23 | + GOARCH: ${{ matrix.goarch }} |
| 24 | + run: | |
| 25 | + make compile |
| 26 | + - name: Upload artifact for docker build step |
| 27 | + uses: actions/upload-artifact@v2 |
| 28 | + with: |
| 29 | + retention-days: 1 |
| 30 | + name: nri-kubernetes-${{ matrix.goos }}-${{ matrix.goarch }} |
| 31 | + path: bin/nri-kubernetes-${{ matrix.goos }}-${{ matrix.goarch }} |
| 32 | + |
8 | 33 | release: |
9 | 34 | name: Release docker images and config |
| 35 | + needs: [ build ] |
10 | 36 | runs-on: ubuntu-latest |
11 | 37 | env: |
12 | 38 | DOCKER_IMAGE_NAME: newrelic/infrastructure-k8s |
| 39 | + DOCKER_PLATFORMS: "linux/amd64,linux/arm64,linux/arm" # Must be consistent with the matrix from the job above |
13 | 40 | S3_PATH: s3://nr-downloads-main/infrastructure_agent |
14 | 41 | steps: |
15 | 42 | - name: Generate docker image version from git tag |
16 | 43 | run: | |
17 | 44 | echo "${{ github.event.release.tag_name }}" | grep -E '^v[0-9.]*[0-9]$' |
18 | 45 | DOCKER_IMAGE_TAG=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//') |
19 | | - echo "$DOCKER_IMAGE_TAG" | grep -E '^[0-9.]*[0-9]$' |
20 | 46 | echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_ENV |
21 | 47 |
|
22 | 48 | - if: ${{ github.event.release.prerelease }} |
23 | 49 | run: | |
24 | | - echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG-pre" >> $GITHUB_ENV |
| 50 | + echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}-pre" >> $GITHUB_ENV |
25 | 51 | echo "S3_PATH=$S3_PATH/test" >> $GITHUB_ENV |
26 | 52 |
|
27 | 53 | - uses: actions/checkout@v2 |
28 | 54 |
|
29 | | -# -pre suffix is stripped from safety checks. This will not be necessary when we automate the yaml generation. |
| 55 | + # -pre suffix is stripped from yaml consistency check |
30 | 56 | - name: Check consistency of deployment yamls |
31 | 57 | run: | |
32 | 58 | grep -e "$DOCKER_IMAGE_NAME:${DOCKER_IMAGE_TAG/-pre}" deploy/newrelic-infra.yaml |
33 | 59 | grep -e "$DOCKER_IMAGE_NAME:${DOCKER_IMAGE_TAG/-pre}" deploy/newrelic-infra-unprivileged.yaml |
34 | 60 |
|
35 | | - - name: Build docker images |
36 | | - run: | |
37 | | - make compile |
38 | | - docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG . |
39 | | - docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-unprivileged --build-arg 'MODE=unprivileged' . |
| 61 | + - name: Set up QEMU |
| 62 | + uses: docker/setup-qemu-action@v1 |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v1 |
| 65 | + |
| 66 | + - name: Download all artifacts from build job |
| 67 | + uses: actions/download-artifact@v2 |
| 68 | + with: |
| 69 | + path: bin |
| 70 | + |
40 | 71 | - uses: docker/login-action@v1 |
41 | 72 | with: |
42 | 73 | username: ${{ secrets.FSI_DOCKERHUB_USERNAME }} |
43 | 74 | password: ${{ secrets.FSI_DOCKERHUB_TOKEN }} |
44 | | - - name: Upload docker images |
| 75 | + |
| 76 | + - name: Build docker images |
| 77 | + run: | |
| 78 | + docker buildx build --platform=$DOCKER_PLATFORMS \ |
| 79 | + -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG \ |
| 80 | + . |
| 81 | + docker buildx build --platform=$DOCKER_PLATFORMS \ |
| 82 | + --build-arg 'MODE=unprivileged' \ |
| 83 | + -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-unprivileged \ |
| 84 | + . |
| 85 | + - name: Push versioned images |
45 | 86 | run: | |
46 | | - docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG |
47 | | - docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-unprivileged |
48 | | - - name: Tag and push docker :latest images |
| 87 | + docker buildx build --push --platform=$DOCKER_PLATFORMS \ |
| 88 | + -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG \ |
| 89 | + . |
| 90 | + docker buildx build --push --platform=$DOCKER_PLATFORMS \ |
| 91 | + --build-arg 'MODE=unprivileged' \ |
| 92 | + -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-unprivileged \ |
| 93 | + . |
| 94 | + - name: Push :latest images |
49 | 95 | if: ${{ ! github.event.release.prerelease }} |
50 | 96 | run: | |
51 | | - docker tag $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG $DOCKER_IMAGE_NAME:latest |
52 | | - docker tag $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-unprivileged $DOCKER_IMAGE_NAME:latest-unprivileged |
53 | | - docker push $DOCKER_IMAGE_NAME:latest |
54 | | - docker push $DOCKER_IMAGE_NAME:latest-unprivileged |
| 97 | + docker buildx build --push --platform=$DOCKER_PLATFORMS \ |
| 98 | + -t $DOCKER_IMAGE_NAME:latest \ |
| 99 | + . |
| 100 | + docker buildx build --push --platform=$DOCKER_PLATFORMS \ |
| 101 | + --build-arg 'MODE=unprivileged' \ |
| 102 | + -t $DOCKER_IMAGE_NAME:latest-unprivileged \ |
| 103 | + . |
55 | 104 |
|
56 | 105 | - uses: aws-actions/configure-aws-credentials@v1 |
57 | 106 | with: |
58 | 107 | aws-access-key-id: ${{ secrets.COREINT_AWS_ACCESS_KEY_ID }} |
59 | 108 | aws-secret-access-key: ${{ secrets.COREINT_AWS_SECRET_ACCESS_KEY }} |
60 | 109 | aws-region: us-east-1 |
61 | | - - name: Upload configuration files to https://download.newrelic.com |
| 110 | + - name: Upload versioned manifests to S3 |
| 111 | + run: | |
| 112 | + aws s3 cp deploy/newrelic-infra.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-${DOCKER_IMAGE_TAG}.yaml |
| 113 | + aws s3 cp deploy/newrelic-infra-unprivileged.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-unprivileged-${DOCKER_IMAGE_TAG}.yaml |
| 114 | + - name: Upload latest manifests to S3 |
| 115 | + if: ${{ ! github.event.release.prerelease }} |
62 | 116 | run: | |
63 | | - aws s3 cp deploy/newrelic-infra.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-$DOCKER_IMAGE_TAG.yaml |
64 | 117 | aws s3 cp deploy/newrelic-infra.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-latest.yaml |
65 | | - aws s3 cp deploy/newrelic-infra-unprivileged.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-unprivileged-$DOCKER_IMAGE_TAG.yaml |
66 | 118 | aws s3 cp deploy/newrelic-infra-unprivileged.yaml $S3_PATH/integrations/kubernetes/newrelic-infrastructure-k8s-unprivileged-latest.yaml |
0 commit comments