Giter Club home page Giter Club logo

s3-sync-cache-invalidate-action's Introduction

GitHub Actions workflow to upload files to AWS S3 bucket after each push to GitHub.

  • Must create an AWS user with permissions that allow writes to S3.

  • Save user credentials.

  • NOTE: If you're using CloudFront, you'll need to add appropriate policy with permission to invalidate cache to the same user.

  • In the GitHub repo, click on 'Settings' then 'Secrets' and 'Actions'.

  • You'll then need to create the appropriate secrets using the name of the AWS_S3_BUCKET, IAM user AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  • NOTE: If you're using CloudFront, you'll need to add another secret for the CloudFront Distribution ID.

  • In the GitHub repo, click on Actions, then 'set up a workflow yourself'.

  • Copy the script at the end of this README into the ./github/workflows/main.yml file GitHub has created, and commit the new file to the repo.

  • Now that the workflow is set up, any commits that are pushed to the repo will automatically be uploaded to the corresponding S3 bucket.

Uploads files to S3 bucket after commit is pushed

name: Upload Website

on:
  push:
    branches:
    - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: jakejarvis/s3-sync-action@master
      with:
        args: --follow-symlinks --delete --exclude '.git*/*'
      env:
        SOURCE_DIR: ./
        AWS_REGION: us-east-1
        AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Invalidates CloudFront cache

    - name: Invalidate CloudFront
      uses: chetan/invalidate-cloudfront-action@v2
      env:
        DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
        PATHS: '/*'
        AWS_REGION: 'us-east-1'
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

s3-sync-cache-invalidate-action's People

Contributors

bryantlogan avatar

Stargazers

 avatar  avatar Biku avatar  avatar

Watchers

 avatar

Forkers

simphiwe20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.