Skip to content

Bump body-parser from 2.2.0 to 2.2.1 in /CoreDeployable in the npm_an… #48

Bump body-parser from 2.2.0 to 2.2.1 in /CoreDeployable in the npm_an…

Bump body-parser from 2.2.0 to 2.2.1 in /CoreDeployable in the npm_an… #48

name: Deploy Kainoscore to Dev
on:
push:
branches:
- main
env:
AWS_REGION: eu-west-2
DEPLOYMENT_ROLE: arn:aws:iam::975050265283:role/GHA-CodeBuild-Service-Role
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
id-token: write
contents: write
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: Dev
outputs:
version: ${{ steps.semver.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Generate semantic version
id: semver
run: |
npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits
cat <<EOF > .releaserc.json
{
"branches": ["main"],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventionalcommits",
"releaseRules": [
{"type": "feat", "release": "minor"},
{"type": "fix", "release": "patch"},
{"type": "docs", "release": "patch"},
{"type": "chore", "release": "patch"},
{"type": "refactor", "release": "patch"},
{"type": "test", "release": "patch"}
]
}],
"@semantic-release/release-notes-generator"
]
}
EOF
echo "Running semantic-release dry-run to calculate next version..."
# Capture semantic-release output and parse the version
SEMANTIC_OUTPUT=$(semantic-release --dry-run 2>&1)
echo "$SEMANTIC_OUTPUT"
# Extract version from semantic-release output
SEMANTIC_VERSION=$(echo "$SEMANTIC_OUTPUT" | grep -oP "The next release version is \K[0-9]+\.[0-9]+\.[0-9]+" || echo "")
# Check if semantic-release determined a version
if [ -n "$SEMANTIC_VERSION" ]; then
echo "Semantic-release determined version: $SEMANTIC_VERSION"
echo "SEMANTIC_VERSION=$SEMANTIC_VERSION" >> $GITHUB_ENV
else
echo "No version determined by semantic-release. Checking for conventional commits..."
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
echo "Latest tag: $LATEST_TAG"
# Get all commits since the last tag
COMMITS_SINCE_TAG=$(git log ${LATEST_TAG}..HEAD --pretty=%B)
# Check if any commit follows conventional commit format
if echo "$COMMITS_SINCE_TAG" | grep -qE "^(feat|fix|docs|chore|refactor|test|perf|ci|build|style)(\(.+\))?:"; then
echo "ERROR: Conventional commits found but semantic-release did not generate a version."
echo "This indicates an issue with semantic-release configuration or commit format."
echo ""
echo "Recent commits:"
echo "$COMMITS_SINCE_TAG"
exit 1
else
echo "ERROR: No conventional commits found since $LATEST_TAG"
echo ""
echo "Please use conventional commit format:"
echo " feat: for new features (minor version bump)"
echo " fix: for bug fixes (patch version bump)"
echo " docs: for documentation changes (patch version bump)"
echo " chore: for maintenance tasks (patch version bump)"
echo " refactor: for code refactoring (patch version bump)"
echo " test: for test updates (patch version bump)"
echo ""
echo "Example: 'feat: add new authentication feature'"
echo ""
echo "Recent commits:"
echo "$COMMITS_SINCE_TAG"
exit 1
fi
fi
echo "Final semantic version: $SEMANTIC_VERSION"
echo "version=$SEMANTIC_VERSION" >> $GITHUB_OUTPUT
- name: Configure AWS credentials via OIDC
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ env.DEPLOYMENT_ROLE }}
aws-region: ${{ env.AWS_REGION }}
- name: Install Typescript and dependencies
run: |
npm install -g typescript
- name: Get Dependency Versions
run: |
echo "NODE.JS version:"
node -v
echo "NPM version:"
npm -v
echo "AWS CLI version:"
aws --version
- name: Application Deployment
id: build-deploy
run: |
echo "Deploying application..."
# make files executable
chmod +x ./pipeline_scripts/application_deploy.sh
chmod +x ./pipeline_scripts/build_core_kfd_api_application.sh
chmod +x ./pipeline_scripts/upload-zip-files.sh
chmod +x ./pipeline_scripts/update-lambda-functions.sh
# Set environment variables directly in this step
export ENVIRONMENT=dev
export SEMANTIC_VERSION=${{ steps.semver.outputs.version }}
# For debugging
echo "Setting ENVIRONMENT=$ENVIRONMENT"
echo "Setting SEMANTIC_VERSION=$SEMANTIC_VERSION"
# run the deployment scripts with version parameter
echo "Running application deployment script...."
./pipeline_scripts/application_deploy.sh "${{ steps.semver.outputs.version }}"
echo "Running KFD api scripts...."
./pipeline_scripts/build_core_kfd_api_application.sh "${{ steps.semver.outputs.version }}"
echo "Running upload-zip-files script...."
./pipeline_scripts/upload-zip-files.sh "${{ steps.semver.outputs.version }}"
echo "Running update-lambda-functions script...."
./pipeline_scripts/update-lambda-functions.sh "${{ steps.semver.outputs.version }}"
# Also add to GITHUB_ENV for subsequent steps
echo "ENVIRONMENT=dev" >> $GITHUB_ENV
echo "SEMANTIC_VERSION=${{ steps.semver.outputs.version }}" >> $GITHUB_ENV
echo "Deployment completed successfully."
- name: Create Git tag
if: success()
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
SEMANTIC_VERSION="${{ steps.semver.outputs.version }}"
if [ -z "$SEMANTIC_VERSION" ]; then
echo "Using version from environment: $SEMANTIC_VERSION"
fi
# Check if tag already exists
if git rev-parse "v$SEMANTIC_VERSION" >/dev/null 2>&1; then
echo "Tag v$SEMANTIC_VERSION already exists. Skipping tag creation."
else
echo "Creating new tag v$SEMANTIC_VERSION"
git tag "v$SEMANTIC_VERSION"
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git "v$SEMANTIC_VERSION"
fi
- name: Setup Firefox
uses: browser-actions/setup-firefox@v1
with:
firefox-version: latest
- name: Run automated tests
id: test-run
working-directory: ./CoreDeployable
env:
TEST_ENVIRONMENT: dev
TEST_URL: ${{ vars.TEST_BASE_URL }}
TEST_HOME_PAGE_URL: https://www.kainos.com/
TEST_API_URL: https://s4ucihjr0e.execute-api.eu-west-2.amazonaws.com
BUCKET_NAME: kainoscore-kfd-files-dev
TEST_AUTH_ISSUER: ${{ secrets.TEST_AUTH_ISSUER }}
TEST_AUTH_CALLBACK: ${{ secrets.TEST_AUTH_CALLBACK }}
TEST_AUTH_IDP_CERT: ${{ secrets.TEST_AUTH_IDP_CERT }}
TEST_AUTH_AUDIENCE: ${{ secrets.TEST_AUTH_AUDIENCE }}
TEST_AUTH_ENTRY_POINT: ${{ secrets.TEST_AUTH_ENTRY_POINT }}
TEST_USERNAME: ${{ secrets.TEST_AUTH_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_AUTH_PASSWORD }}
run: |
echo "Starting automated test execution against DEV environment..."
echo "Test Environment: $TEST_ENVIRONMENT"
echo "Base URL: $TEST_BASE_URL"
npm install
npm run test
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-dev-${{ steps.semver.outputs.version }}
path: |
CoreDeployable/test/cucumber-report.html
retention-days: 30