diff --git a/.github/workflows/amplify-deployment.yml b/.github/workflows/amplify-deployment.yml index 88c58ac..3a50393 100644 --- a/.github/workflows/amplify-deployment.yml +++ b/.github/workflows/amplify-deployment.yml @@ -38,7 +38,7 @@ jobs: - name: Verify Amplify CLI Installation run: amplify --version - add-credentials: + assume-role: runs-on: ubuntu-latest needs: install-cli steps: @@ -50,7 +50,7 @@ jobs: deploy-amplify: runs-on: ubuntu-latest - needs: [checkout-code, add-credentials, install-cli] + needs: [checkout-code, assume-role, install-cli] steps: - name: Fetch API URL from SSM id: fetch-ssm diff --git a/.github/workflows/serverless-deployment.yml b/.github/workflows/serverless-deployment.yml new file mode 100644 index 0000000..1487620 --- /dev/null +++ b/.github/workflows/serverless-deployment.yml @@ -0,0 +1,59 @@ +name: Deploy with Serverless Framework + +permissions: + id-token: write + contents: read + +on: + push: + branches: + - main + paths: + - "tasker-server/**" + +jobs: + checkout-code: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + install-deps: + runs-on: ubuntu-latest + needs: checkout-code + steps: + - name: Install AWS CLI + run: | + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install + + - name: Verify AWS CLI Installation + run: aws --version + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Install Serverless Framework + run: npm install -g serverless + + assume-role: + runs-on: ubuntu-latest + needs: install-deps + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: ${{ secrets.AWS_REGION }} + + deploy-serverless: + runs-on: ubuntu-latest + needs: [checkout-code, assume-role, install-deps] + steps: + - name: Deploy Serverless Application + run: | + cd tasker-server + serverless deploy