Home > database >  Download file from s3 then store the files into the github repository
Download file from s3 then store the files into the github repository

Time:09-13

I have files stored in an AWS S3 bucket. I would like to use GitHub actions to download those files and put them into my GitHub repository. Furthermore, I am able to download the files, but I cannot seem to get the files to then go into my repository. Here are the attempts I have made.

    steps:
    - name: Download from S3
      run: |
        aws s3 cp --recursive aws-bucket myDirectoryIWantTheFilesIn
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_DEFAULT_REGION: 'us-east-1'

I have tried as well with the aws-s3-github-actions

     - name: copy sitemaps
       uses: keithweaver/[email protected]
       with:
         command: cp
         source: awsS3Bucket
         destination: myDirectoryIWantTheFilesIn
         aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
         aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
         aws_region: us-east-1
         flags: --recursive

CodePudding user response:

I needed to include the action's checkout and then commit it.

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions


# This is a basic workflow to help you get started with Actions

name: Fetch data.

# Controls when the workflow will run
on:
  schedule:
    # Runs "at hour 6 past every day" (see https://crontab.guru)
    - cron: '00 6 * * *'
    
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: keithweaver/[email protected] # Verifies the recursive flag
        name: cp folder
        with:
          command: cp
          source: myBucket
          destination: myDestination
          aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws_region: us-east-1
          flags: --recursive
      - name: Commit changes
        run: |
         git config --local user.email "[email protected]"
         git config --local user.name "GitHub Action"
         git add .
         git diff-index --quiet HEAD || git commit -m "MyCommitMessage" -a
         git push origin master

CodePudding user response:

You can mark this as duplicate

You may have your answer here

S3 to github

  • Related