Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paschalidi/4e2fb94021c8c9146cf2490786372988 to your computer and use it in GitHub Desktop.
Save paschalidi/4e2fb94021c8c9146cf2490786372988 to your computer and use it in GitHub Desktop.
name: CI/CD
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v1
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
env:
CI: true
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@master
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm ci
- name: Build Package
run: npm run build
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: public
path: public
- name: Deploy to S3
if: github.ref == 'refs/heads/master'
uses: actions/aws/cli@master
with:
args: s3 cp ./public s3://dash-plumbing --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Invalidate Cloudfront CDN
if: github.ref == 'refs/heads/master'
uses: actions/aws/cli@master
with:
args: cloudfront create-invalidation --distribution-id=$CLOUDFRONT_DISTRIBUTION_ID --paths '/*'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFRONT_DISTRIBUTION_ID: <<INSERT DISTRIBUTION ID HERE>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment