diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 761f189a..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,89 +0,0 @@ -version: 2.1 -executors: - node-executor: - docker: - - image: cimg/node:20.11.1 - working_directory: ~/repo - -orbs: - helix-post-deploy: adobe/helix-post-deploy@3.0.3 - codecov: codecov/codecov@5.0.3 - -commands: - setup: - steps: - - checkout - - run: - name: Installing Dependencies - command: npm ci - - run: - name: prepare test git user - command: git config --global user.email "circleci@example.com" && git config --global user.name "CircleCi Build" - -jobs: - build: - executor: node-executor - steps: - - setup - - run: mkdir junit - - run: - name: Lint - command: npm run lint - - run: - name: Getting Code Coverage - command: npm run test - - codecov/upload - - store_test_results: - path: junit - - store_artifacts: - path: junit - - semantic-release: - executor: node-executor - steps: - - setup - - run: - name: revert changes to package-lock.json - command: git checkout -- package-lock.json - - helix-post-deploy/config-env - - run: - name: Semantic Release - command: npm run semantic-release - - store_test_results: - path: junit - - branch-deploy: - executor: node-executor - steps: - - setup - - run: - name: revert changes to package-lock.json - command: git checkout -- package-lock.json - - run: - name: Branch Deployment - command: npm run deploy-ci - - run: - name: Post-Deployment Integration Test - command: npm run test-postdeploy - - store_test_results: - path: junit - -workflows: - version: 2 - build: - jobs: - - build - - branch-deploy: - context: Spacecat - requires: - - build - filters: - branches: - ignore: main - - semantic-release: - context: Spacecat - requires: - - build - filters: - branches: - only: main diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..d3fa0981 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,134 @@ +name: CI + +permissions: + id-token: write + contents: write + issues: read + +on: [push] + +env: + CI_BUILD_NUM: ${{ github.run_id }} + CI_BRANCH: ${{ github.ref_name }} + HLX_AWS_REGION: ${{ secrets.AWS_REGION }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.12 + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + - name: Getting Code Coverage + run: npm run test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Semantic Release (Dry Run) + if: github.ref != 'refs/heads/main' + run: npm run semantic-release-dry + env: + GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} + + semantic-release: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.12 + + - name: Install dependencies + run: npm ci + + - name: Revert changes to package-lock.json + run: git checkout -- package-lock.json + + - name: Configure Environment + run: echo -e "LOG_LEVEL=info\n" > .env + + - name: Configure AWS Credentials + id: creds + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-east-1 + role-to-assume: arn:aws:iam::282898975672:role/spacecat-role-github-actions + + - name: Fetch AWS Secrets + uses: aws-actions/aws-secretsmanager-get-secrets@v2 + with: + parse-json-secrets: true + secret-ids: | + /spacecat/github-action-secrets + + - name: Semantic Release + run: npm run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} + + branch-deploy: + runs-on: ubuntu-latest + needs: build + if: github.ref != 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.12 + + - name: Install dependencies + run: npm ci + + - name: Revert changes to package-lock.json + run: git checkout -- package-lock.json + + - name: Configure AWS Credentials + id: creds + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-east-1 + role-to-assume: arn:aws:iam::282898975672:role/spacecat-role-github-actions + + - name: Fetch AWS Secrets + uses: aws-actions/aws-secretsmanager-get-secrets@v2 + with: + parse-json-secrets: true + secret-ids: | + /spacecat/github-action-secrets + + - name: Branch Deployment + run: npm run deploy-ci + env: + AWS_REGION: us-east-1 + + - name: Post-Deployment Integration Test + run: npm run test-postdeploy + + - name: Upload post-deployment coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/package.json b/package.json index d5ae44e0..b828b214 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,11 @@ "lint": "eslint .", "logs": "aws logs tail /aws/lambda/spacecat-services--audit-worker", "semantic-release": "semantic-release", - "semantic-release-dry": "semantic-release --dry-run --no-ci --branches $CIRCLE_BRANCH", + "semantic-release-dry": "semantic-release --dry-run --no-ci --branches $CI_BRANCH", "build": "hedy -v --test-bundle", "deploy": "hedy -v --deploy --test", "deploy-routes": "hedy --no-build -no-hints -l major", - "deploy-ci": "hedy -v --deploy --test --pkgVersion=ci$CIRCLE_BUILD_NUM -l ci --cleanup-ci=24h", + "deploy-ci": "hedy -v --deploy --test --pkgVersion=ci$CI_BUILD_NUM -l ci --cleanup-ci=24h", "deploy-secrets": "hedy --aws-update-secrets --params-file=secrets/secrets.env", "prepare": "husky" }, @@ -31,7 +31,7 @@ }, "fastlyServiceId!important": "", "timeout": 900000, - "nodeVersion": 20 + "nodeVersion": 22 }, "repository": { "type": "git",