Workflow file for this run
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: 🚀 CI/CD Codigo Azteca prod y pruebas | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- WorkflowCI/CDsemanticversioning | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- dev | |
- main | |
- WorkflowCI/CDsemanticversioning | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
actions: write | |
contents: read | |
jobs: | |
lint-and-test: | |
name: Lint, Test, and Check Formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "20.x" | |
- name: Cache Dependencies and Builds | |
uses: actions/cache@v3 | |
with: | |
path: | | |
.next/ | |
.open-next/ | |
.sst/ | |
node_modules/ | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Install Dependencies | |
run: npm install | |
- name: Check Formatting with Prettier | |
run: npm run prettier:check | |
- name: Lint | |
run: npm run lint | |
if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/WorkflowCI/CDsemanticversioning') && (github.event_name == 'push' || github.event_name == 'pull_request') | |
deploy-to-dev: | |
name: Deploy to Dev | |
runs-on: ubuntu-latest | |
needs: lint-and-test | |
if: (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/WorkflowCI/CDsemanticversioning') && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup AWS Credentials | |
run: | | |
mkdir -p ~/.aws | |
echo "[default]" > ~/.aws/credentials | |
echo "aws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials | |
echo "aws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials | |
- name: Deploy to AWS with SST | |
run: npm run deployStaging | |
- name: Clean up AWS profile | |
run: rm -rf ~/.aws | |
deploy-to-production: | |
name: Deploy to Production | |
runs-on: ubuntu-latest | |
needs: lint-and-test | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup AWS Credentials | |
run: | | |
mkdir -p ~/.aws | |
echo "[default]" > ~/.aws/credentials | |
echo "aws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials | |
echo "aws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials | |
- name: Deploy to AWS with SST | |
run: npm run deploy | |
- name: Clean up AWS profile | |
run: rm -rf ~/.aws | |
rollback: | |
name: Rollback to Previous Version | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.version }} | |
- name: Setup AWS Credentials | |
run: | | |
mkdir -p ~/.aws | |
echo "[default]" > ~/.aws/credentials | |
echo "aws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials | |
echo "aws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials | |
- name: Deploy to AWS with SST (Rollback) | |
run: npm run deploy # mismo comando que para deploy-to-production | |
- name: Clean up AWS profile | |
run: rm -rf ~/.aws |