Repository navigation
fix deployment and add events #42
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: build npm sent S3 | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - "k8s/updated-version_prod.yml" | |
| env: | |
| CLUSTER_NAME: goat-mainnet | |
| BUILD_ENV: mainnet | |
| S3_BUCKET: static-goat-docs-prod | |
| CLOUDFRONT_ID: E3QEUVXOL39T5M | |
| jobs: | |
| build-and-deploy: | |
| name: Build and Deploy Module | |
| runs-on: ubuntu-latest | |
| environment: prod | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Echo Active Profile | |
| run: | | |
| echo "Active profile: testnet" | |
| - name: npm install, build, and testnet | |
| run: | | |
| npm install | |
| npm run build | |
| - name: Sync S3 Bucket | |
| run: | | |
| MAX_RETRIES=3 | |
| for i in $(seq 1 $MAX_RETRIES); do | |
| echo "Attempt $i to sync files to S3..." | |
| aws s3 sync ./out/ s3://$S3_BUCKET/ \ | |
| --delete \ | |
| --debug && break || \ | |
| echo "Attempt $i/$MAX_RETRIES failed. Retrying in 5 seconds..." && sleep 5; | |
| done | |
| if [ $i -eq $MAX_RETRIES ]; then | |
| echo "Sync failed after $MAX_RETRIES attempts." && exit 1 | |
| fi | |
| - name: Refresh CDN Cache | |
| run: | | |
| aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID --paths "/*" |