Merge pull request #167 from EladHeller/dependabot/npm_and_yarn/devel… #150
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: CD | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
jobs: | |
env_detect: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Detect env | |
id: branch_check | |
run: | | |
echo "Running on branch ${{ github.ref }}" | |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
echo "env_name=prod" >> $GITHUB_OUTPUT | |
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then | |
echo "env_name=dev" >> $GITHUB_OUTPUT | |
fi | |
- name: Use variable setup in previous step | |
run: echo "I'm using variable ${{ steps.branch_check.outputs.env_name }}" | |
outputs: | |
env_name: ${{ steps.branch_check.outputs.env_name }} | |
deploy: | |
needs: | |
- env_detect | |
environment: | |
name: ${{ needs.env_detect.outputs.env_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules-v1 | |
with: | |
path: ~/.npm | |
key: deploy-cache-node-modules-v1-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci | |
- 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: Build code | |
run: | | |
export REGION=${{ secrets.AWS_REGION }} | |
export CODE_BUCKET=${{ secrets.CODE_BUCKET_NAME }} | |
export CURR_ELECTIONS=${{ secrets.CURR_ELECTIONS }} | |
export CLIENT_CODE_BUCKET=${{ secrets.CLIENT_CODE_BUCKET }} | |
npm run update-env | |
npm run update-lambda |