test(e2e): add configuration that allows to e2e test #798
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Release | |
on: | |
push: | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: write | |
issues: write | |
env: | |
CI: 1 | |
FORCE_COLOR: 3 | |
jobs: | |
test-and-release: | |
runs-on: ubuntu-22.04 | |
environment: ci | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
- name: Keep npm cache around to speed up installs | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: build-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci --no-audit | |
- name: Check TypeScript | |
run: npx tsc | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
role-session-name: github-action-public-parameter-registry | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Generate Stack ID | |
run: | | |
RANDOM_STRING=`node -e "const crypto = require('crypto'); process.stdout.write(crypto.randomBytes(Math.ceil(8 * 0.5)).toString('hex').slice(0, 8));"` | |
echo "STACK_NAME_PREFIX=tsci-${RANDOM_STRING}" >> $GITHUB_ENV | |
- name: Deploy solution | |
run: npx cdk deploy --require-approval never | |
- name: Export settings | |
run: | | |
TABLE_NAME=`aws cloudformation describe-stacks --stack-name ${STACK_NAME_PREFIX:-teamstatus}-backend | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == "tableName") | .OutputValue'` | |
echo "TABLE_NAME=${TABLE_NAME}" >> $GITHUB_ENV | |
- name: Run Tests | |
run: npm test | |
- name: Semantic release | |
if: github.ref == 'refs/heads/saga' | |
id: semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release | |
- name: Destroy solution stack | |
if: always() | |
run: npx cdk destroy -f |