From e06f7c6c37b32454cbe3f1f54c3153657050a9af Mon Sep 17 00:00:00 2001 From: MarceloVichar Date: Wed, 24 Jan 2024 16:25:34 -0300 Subject: [PATCH] cd s3 --- .github/workflows/deploy.yaml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..78d257a --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,52 @@ +name: CI/CD - Production - Pipeline + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + deployment: + + runs-on: ubuntu-latest + + env: + ENV: production + NUXT_PUBLIC_API_BASE: https://api.lets.tur.br + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_S3_REGION }} + + - name: Repository Name + run: echo ${{ github.repository }} + + - name: Get bucket name + id: get-bucket-name + run: echo "::set-output name=name::v2.lets.tur.br" + + - name: S3 Search + id: s3-search-bucket + run: echo "::set-output name=code::$(aws s3 ls s3://${{ steps.get-bucket-name.outputs.name }} || echo $?)" + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 20.x + + - name: Install dependencies + run: npm i + + - name: Build + run: npm run build + + - name: S3 Sync + if: success() + run: aws s3 sync dist/ s3://${{ steps.get-bucket-name.outputs.name }} \ No newline at end of file