DAPP1-87: updated ci file #32
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: Continuous Integration and Deployment | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
continuous_integration: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout code 🛎️ | |
uses: actions/checkout@v3 | |
with: | |
clean: true | |
- name: Set Node Version | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.13.1 | |
- name: Setup .npmrc file | |
run: | | |
echo "@3um-group:registry=https://npm.pkg.github.com/" > ~/.npmrc | |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
- name: Install Packages | |
run: npm install --legacy-peer-deps | |
# - name: Run Test | |
# run: npm run test | |
- name: Build Project | |
run: npm run build | |
- name: Check for .codesandbox/tasks.json | |
run: | | |
if [ ! -f .codesandbox/tasks.json ]; then | |
echo "Error: .codesandbox/tasks.json not found" | |
exit 1 | |
fi | |
- name: Deploy to CodeSandbox | |
env: | |
CODESANDBOX_TOKEN: ${{ secrets.CODESANDBOX_API_TOKEN }} | |
run: | | |
# Install CodeSandbox CLI | |
npm install -g codesandbox | |
# Deploy to CodeSandbox | |
SANDBOX_URL=$(codesandbox deploy --json | jq -r '.url') | |
echo "Sandbox URL: $SANDBOX_URL" | |
echo "SANDBOX_URL=$SANDBOX_URL" >> $GITHUB_ENV | |
- name: Comment PR | |
uses: actions/github-script@v6 | |
if: github.event_name == 'pull_request' | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Deployed to CodeSandbox: ${process.env.SANDBOX_URL}` | |
}) |