Skip to content

Test action

Test action #2

name: TEST-ENV-DEPLOYMENT
# Build and deploy test instance for every pull request
on:
pull_request:
types: [reopened, synchronize, labeled]
branches: ["**"]
jobs:
deploy:
name: Deploy test environment for labeled pull requests
if: ${{ ((github.event.action == 'labeled') && (github.event.label.name == 'test deployment')) || ((github.event.action != 'labeled') && contains(github.event.pull_request.labels.*.name, 'test deployment')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/[email protected]
- name: Set domain
id: set-domain
# Set test instance domain based on branch name slug
run: |
echo "domain=${{ env.GITHUB_HEAD_REF_SLUG_URL }}.api.saleor.rocks" >> $GITHUB_OUTPUT
- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
ref: ${{ github.head_ref }}
- name: Build and push
uses: kciter/aws-ecr-action@79255b7c5aa03dbf6d7c46cff2bfd049874cd98d # v4
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_URL }},${{ 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_URL }}",
"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://${{ steps.set-domain.outputs.domain }}/graphql/
deployment_id: ${{ steps.deployment.outputs.deployment_id }}