|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2025-Present Datadog, Inc. |
| 4 | + |
| 5 | +name: Print Service |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: ["main"] |
| 13 | + pull_request: |
| 14 | + branches: ["main"] |
| 15 | + paths: |
| 16 | + - "print-service/**" |
| 17 | + - ".github/**" |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +env: |
| 21 | + REGISTRY: ghcr.io |
| 22 | + IMAGE_NAME_PRINT_SERVICE: ${{ github.repository_owner }}/stickerlandia/print-service |
| 23 | + IMAGE_NAME_PRINT_WORKER: ${{ github.repository_owner }}/stickerlandia/print-service-worker |
| 24 | + IMAGE_NAME_PRINT_MIGRATION: ${{ github.repository_owner }}/stickerlandia/print-service-migration |
| 25 | + REPOSITORY_URL: github.com/${{ github.repository }} |
| 26 | + |
| 27 | +jobs: |
| 28 | + unit-test: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 32 | + - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 #4.3.1 |
| 33 | + with: |
| 34 | + dotnet-version: "10.0.x" |
| 35 | + - name: Format Code |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + cd print-service |
| 39 | + dotnet format |
| 40 | + - name: Run Unit Tests |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + cd print-service/tests/Stickerlandia.PrintService.UnitTest |
| 44 | + dotnet test |
| 45 | +
|
| 46 | + integration-test-aws: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: unit-test |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + DRIVING: |
| 52 | + - AWS |
| 53 | + fail-fast: false |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 57 | + - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 #4.3.1 |
| 58 | + with: |
| 59 | + dotnet-version: "10.0.x" |
| 60 | + - name: Install SSL Certificates |
| 61 | + run: | |
| 62 | + dotnet dev-certs https --trust |
| 63 | + - name: .NET Restore |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + cd print-service |
| 67 | + dotnet restore Stickerlandia.PrintService.sln |
| 68 | + - name: Run Integration Tests |
| 69 | + shell: bash |
| 70 | + env: |
| 71 | + DRIVING: ${{ matrix.DRIVING }} |
| 72 | + DRIVEN: AWS |
| 73 | + run: | |
| 74 | + cd print-service/tests/Stickerlandia.PrintService.IntegrationTest && dotnet test --logger:"console;verbosity=detailed" |
| 75 | +
|
| 76 | + integration-test-agnostic: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: unit-test |
| 79 | + strategy: |
| 80 | + matrix: |
| 81 | + DRIVING: |
| 82 | + - AGNOSTIC |
| 83 | + fail-fast: false |
| 84 | + |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 87 | + - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 #4.3.1 |
| 88 | + with: |
| 89 | + dotnet-version: "10.0.x" |
| 90 | + - name: Install SSL Certificates |
| 91 | + run: | |
| 92 | + dotnet dev-certs https --trust |
| 93 | + - name: .NET Restore |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + cd print-service |
| 97 | + dotnet restore Stickerlandia.PrintService.sln |
| 98 | + - name: Run Integration Tests |
| 99 | + shell: bash |
| 100 | + env: |
| 101 | + DRIVING: ${{ matrix.DRIVING }} |
| 102 | + DRIVEN: AGNOSTIC |
| 103 | + run: | |
| 104 | + cd print-service/tests/Stickerlandia.PrintService.IntegrationTest && dotnet test --logger:"console;verbosity=detailed" |
| 105 | +
|
| 106 | + push-image: |
| 107 | + runs-on: ubuntu-latest |
| 108 | + needs: [ |
| 109 | + integration-test-aws, |
| 110 | + integration-test-agnostic |
| 111 | + ] |
| 112 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 113 | + permissions: |
| 114 | + contents: read |
| 115 | + packages: write |
| 116 | + attestations: write |
| 117 | + id-token: write |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 120 | + - name: Get Commit Info |
| 121 | + id: get_sha |
| 122 | + run: | |
| 123 | + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 124 | + echo "COMMIT_SHA_FULL=$(git rev-parse HEAD)" >> $GITHUB_ENV |
| 125 | +
|
| 126 | + - name: Set up Docker Buildx |
| 127 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 128 | + |
| 129 | + - name: Log in to the Container registry |
| 130 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 131 | + with: |
| 132 | + registry: ${{ env.REGISTRY }} |
| 133 | + username: ${{ github.actor }} |
| 134 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 135 | + |
| 136 | + - name: Extract metadata (tags, labels) for Docker |
| 137 | + id: meta |
| 138 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 139 | + with: |
| 140 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PRINT_SERVICE }} |
| 141 | + tags: | |
| 142 | + latest |
| 143 | + ${{ env.COMMIT_SHA }} |
| 144 | +
|
| 145 | + - name: Build and push Docker image |
| 146 | + id: push |
| 147 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 148 | + with: |
| 149 | + context: ./print-service |
| 150 | + file: ./print-service/src/Stickerlandia.PrintService.Api/Dockerfile |
| 151 | + platforms: linux/amd64,linux/arm64 |
| 152 | + push: true |
| 153 | + tags: ${{ steps.meta.outputs.tags }} |
| 154 | + labels: ${{ steps.meta.outputs.labels }} |
| 155 | + build-args: | |
| 156 | + GIT_COMMIT_SHA=${{ env.COMMIT_SHA_FULL }} |
| 157 | + DD_GIT_COMMIT_SHA=${{ env.COMMIT_SHA_FULL }} |
| 158 | + GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 159 | + DD_GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 160 | +
|
| 161 | + push-worker-service: |
| 162 | + runs-on: ubuntu-latest |
| 163 | + needs: [ |
| 164 | + integration-test-aws, |
| 165 | + integration-test-agnostic |
| 166 | + ] |
| 167 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 168 | + permissions: |
| 169 | + contents: read |
| 170 | + packages: write |
| 171 | + attestations: write |
| 172 | + id-token: write |
| 173 | + steps: |
| 174 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 175 | + - name: Get Commit Info |
| 176 | + id: get_sha |
| 177 | + run: | |
| 178 | + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 179 | +
|
| 180 | + - name: Set up Docker Buildx |
| 181 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 182 | + |
| 183 | + - name: Log in to the Container registry |
| 184 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 185 | + with: |
| 186 | + registry: ${{ env.REGISTRY }} |
| 187 | + username: ${{ github.actor }} |
| 188 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 189 | + |
| 190 | + - name: Extract metadata (tags, labels) for Docker |
| 191 | + id: meta |
| 192 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 193 | + with: |
| 194 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PRINT_WORKER }} |
| 195 | + tags: | |
| 196 | + latest |
| 197 | + ${{ env.COMMIT_SHA }} |
| 198 | +
|
| 199 | + - name: Build and push Docker image |
| 200 | + id: push |
| 201 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 202 | + with: |
| 203 | + context: ./print-service |
| 204 | + file: ./print-service/src/Stickerlandia.PrintService.Worker/Dockerfile |
| 205 | + platforms: linux/amd64,linux/arm64 |
| 206 | + push: true |
| 207 | + tags: ${{ steps.meta.outputs.tags }} |
| 208 | + labels: ${{ steps.meta.outputs.labels }} |
| 209 | + build-args: | |
| 210 | + GIT_COMMIT_SHA=${{ env.COMMIT_SHA }} |
| 211 | + GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 212 | + DD_GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 213 | + DD_GIT_COMMIT_SHA=${{ env.COMMIT_SHA }} |
| 214 | +
|
| 215 | + push-migration-service: |
| 216 | + runs-on: ubuntu-latest |
| 217 | + needs: [ |
| 218 | + integration-test-aws, |
| 219 | + integration-test-agnostic |
| 220 | + ] |
| 221 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 222 | + permissions: |
| 223 | + contents: read |
| 224 | + packages: write |
| 225 | + attestations: write |
| 226 | + id-token: write |
| 227 | + steps: |
| 228 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 229 | + - name: Get Commit Info |
| 230 | + id: get_sha |
| 231 | + run: | |
| 232 | + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 233 | +
|
| 234 | + - name: Set up Docker Buildx |
| 235 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 236 | + |
| 237 | + - name: Log in to the Container registry |
| 238 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 239 | + with: |
| 240 | + registry: ${{ env.REGISTRY }} |
| 241 | + username: ${{ github.actor }} |
| 242 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 243 | + |
| 244 | + - name: Extract metadata (tags, labels) for Docker |
| 245 | + id: meta |
| 246 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 247 | + with: |
| 248 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PRINT_MIGRATION }} |
| 249 | + tags: | |
| 250 | + latest |
| 251 | + ${{ env.COMMIT_SHA }} |
| 252 | +
|
| 253 | + - name: Build and push Docker image |
| 254 | + id: push |
| 255 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 256 | + with: |
| 257 | + context: ./print-service |
| 258 | + file: ./print-service/src/Stickerlandia.PrintService.MigrationService/Dockerfile |
| 259 | + platforms: linux/amd64,linux/arm64 |
| 260 | + push: true |
| 261 | + tags: ${{ steps.meta.outputs.tags }} |
| 262 | + labels: ${{ steps.meta.outputs.labels }} |
| 263 | + build-args: | |
| 264 | + GIT_COMMIT_SHA=${{ env.COMMIT_SHA }} |
| 265 | + GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 266 | + DD_GIT_REPOSITORY_URL=${{ env.REPOSITORY_URL }} |
| 267 | + DD_GIT_COMMIT_SHA=${{ env.COMMIT_SHA }} |
| 268 | +
|
| 269 | + deploy-aws-dev: |
| 270 | + runs-on: ubuntu-latest |
| 271 | + needs: [push-image, push-migration-service] |
| 272 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 273 | + permissions: |
| 274 | + contents: read |
| 275 | + packages: write |
| 276 | + attestations: write |
| 277 | + id-token: write |
| 278 | + steps: |
| 279 | + - name: Checkout |
| 280 | + uses: actions/checkout@v4 |
| 281 | + - name: Set up Node |
| 282 | + uses: actions/setup-node@v3 |
| 283 | + with: |
| 284 | + node-version: "20" |
| 285 | + - name: Install CDK |
| 286 | + run: | |
| 287 | + npm install -g aws-cdk |
| 288 | + - name: Install dependencies |
| 289 | + shell: bash |
| 290 | + run: | |
| 291 | + cd shared/lib/shared-constructs |
| 292 | + npm i |
| 293 | + - uses: actions/setup-dotnet@v4 |
| 294 | + with: |
| 295 | + dotnet-version: "10.0.x" |
| 296 | + - name: Configure AWS credentials |
| 297 | + uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df |
| 298 | + with: |
| 299 | + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} |
| 300 | + role-session-name: GitHub_to_AWS_via_FederatedOIDC |
| 301 | + aws-region: "eu-west-1" |
| 302 | + - name: Set Commit Hash Environment Variables |
| 303 | + shell: bash |
| 304 | + run: | |
| 305 | + echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV" |
| 306 | + - name: Deploy to dev AWS |
| 307 | + shell: bash |
| 308 | + env: |
| 309 | + VERSION: ${{ env.sha_short }} |
| 310 | + ENV: "dev" |
| 311 | + DD_API_KEY: ${{secrets.DD_API_KEY}} |
| 312 | + DD_SITE: "datadoghq.com" |
| 313 | + run: | |
| 314 | + cd print-service/infra/aws |
| 315 | + npm i |
| 316 | + cdk deploy --require-approval never |
0 commit comments