sync to cookbook 7.1 and add pipeline #10
Workflow file for this run
This file contains hidden or 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: Cookiecutter Template Test | |
| permissions: | |
| contents: read | |
| env: | |
| NODE_VERSION: "20" | |
| PYTHON_VERSION: "3.13" | |
| AWS_REGION: "us-east-1" | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| environment: ci | |
| permissions: | |
| id-token: write # required for requesting the JWT (GitHub OIDC) | |
| steps: | |
| - run: | | |
| echo "🎉 The job was automatically triggered by a ${{ env.EVENT_NAME }} event." >> $GITHUB_STEP_SUMMARY | |
| echo "🐧 This job is now running on a ${{ env.OS_NAME }} ${{env.OS_ARCH}} server hosted by GitHub!" >> $GITHUB_STEP_SUMMARY | |
| echo "🔎 The name of your branch is ${{ env.BRANCH_NAME }} and your repository is ${{ env.REPO_NAME }}." >> $GITHUB_STEP_SUMMARY | |
| env: | |
| EVENT_NAME: ${{ github.event_name}} | |
| OS_NAME: ${{ runner.os }} | |
| OS_ARCH: ${{runner.arch }} | |
| BRANCH_NAME: ${{ github.ref }} | |
| REPO_NAME: ${{ github.repository }} | |
| - name: Check out repository code | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up Python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install poetry | |
| run: pipx install poetry | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip poetry | |
| poetry config --local virtualenvs.in-project true | |
| poetry install --no-root | |
| npm ci | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE }} | |
| role-session-name: ${{ env.SESSION_NAME }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| env: | |
| SESSION_NAME: "github-${{github.sha}}-dev" | |
| - name: Run Cookiecutter with predefined answers | |
| run: | | |
| # Create a cookiecutter-answers.json file with predefined answers | |
| cat > cookiecutter-answers.json << EOF | |
| { | |
| "repo_name": "test_serverless_service", | |
| "service_name": "test_service", | |
| "email": "test@example.com", | |
| "author": "Test User", | |
| "description": "A test serverless service for CI" | |
| } | |
| EOF | |
| # Run cookiecutter with the answers file | |
| poetry run cookiecutter --no-input -f --config-file cookiecutter-answers.json . | |
| # List the created directories for debugging | |
| echo "Listing directories in current path:" | |
| ls -la | |
| - name: Set up Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Run make pr command | |
| run: | | |
| # Check what directories are available before trying to enter | |
| echo "Available directories:" | |
| ls -la | |
| # Try to find the generated directory | |
| GENERATED_DIR=$(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "." | head -1) | |
| if [ -z "$GENERATED_DIR" ]; then | |
| echo "No generated directory found. Cookiecutter may have failed." | |
| exit 1 | |
| fi | |
| echo "Found generated directory: $GENERATED_DIR" | |
| cd "$GENERATED_DIR" | |
| echo "Now in directory: $(pwd)" | |
| ls -la | |
| make pr | |
| - name: Destroy stack | |
| if: always() | |
| run: | | |
| # Try to find the generated directory | |
| GENERATED_DIR=$(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "." | head -1) | |
| if [ -n "$GENERATED_DIR" ]; then | |
| echo "Cleaning up in directory: $GENERATED_DIR" | |
| cd "$GENERATED_DIR" | |
| make destroy | |
| else | |
| echo "No generated directory found, nothing to destroy." | |
| fi |