Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add test env deployment workflows

Cezary Miącze03169414b31
diff --git a/.github/workflows/test-env-cleanup.yml b/.github/workflows/test-env-cleanup.yml
new file mode 100644
index 0000000000..0185832bfd
--- /dev/null
+++ b/.github/workflows/test-env-cleanup.yml
@@ -0,0 +1,36 @@
+name: TEST-ENV-CLEANUP
+# Build and deploy test instance for every pull request
+
+on:
+ pull_request:
+ # trigger on "edited" to update instance when configuration changes in PR description
+ types: [closed]
+ branches: ["*"]
+
+jobs:
+ cleanup:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: rlespinasse/[email protected]
+
+ - name: Invoke deployment lambda
+ uses: gagoar/[email protected]
+ with:
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ REGION: us-east-1
+ FunctionName: test-env-manager
+ Payload: >-
+ {
+ "action": "${{ github.event.action }}",
+ "label": "${{ env.GITHUB_HEAD_REF_SLUG }}",
+ "image": "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/saleor-testenvs:${{ env.GITHUB_HEAD_REF_SLUG }}"
+ }
+ LogType: Tail
+
+ - name: Mark deployment as deactivated
+ uses: bobheadxi/[email protected]
+ with:
+ step: deactivate-env
+ token: ${{ secrets.GITHUB_TOKEN }}
+ env: ${{ env.GITHUB_HEAD_REF_SLUG }}
diff --git a/.github/workflows/test-env-deploy.yml b/.github/workflows/test-env-deploy.yml
new file mode 100644
index 0000000000..fc94faa787
--- /dev/null
+++ b/.github/workflows/test-env-deploy.yml
@@ -0,0 +1,64 @@
+name: TEST-ENV-DEPLOYMENT
+# Build and deploy test instance for every pull request
+
+on:
+ pull_request:
+ # trigger on "edited" to update instance when configuration changes in PR description
+ types: [opened, reopened, synchronize]
+ branches: ["*"]
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: rlespinasse/[email protected]
+
+ - name: Set domain
+ # Set test instance domain based on branch name slug
+ run: |
+ echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.api.saleor.rocks"
+
+ - name: Start deployment
+ uses: bobheadxi/[email protected]
+ id: deployment
+ with:
+ step: start
+ token: ${{ secrets.GITHUB_TOKEN }}
+ env: ${{ env.GITHUB_HEAD_REF_SLUG }}
+ ref: ${{ github.head_ref }}
+
+ - name: Build and push
+ uses: kciter/aws-ecr-action@v1
+ with:
+ access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ account_id: ${{ secrets.AWS_ACCOUNT_ID }}
+ repo: saleor-testenvs
+ region: us-east-1
+ tags: ${{ env.GITHUB_HEAD_REF_SLUG }},${{ github.sha }}
+
+ - name: Invoke deployment lambda
+ uses: gagoar/[email protected]
+ with:
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ REGION: us-east-1
+ FunctionName: test-env-manager
+ Payload: >-
+ {
+ "action": "${{ github.event.action }}",
+ "label": "${{ env.GITHUB_HEAD_REF_SLUG }}",
+ "image": "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/saleor-testenvs:${{ github.sha }}"
+ }
+ LogType: Tail
+
+ - name: Update deployment status
+ uses: bobheadxi/[email protected]
+ if: always()
+ with:
+ step: finish
+ token: ${{ secrets.GITHUB_TOKEN }}
+ status: ${{ job.status }}
+ env_url: https://${{ env.domain }}/graphql/
+ deployment_id: ${{ steps.deployment.outputs.deployment_id }}