Github Actions でテスト用のS3を使う


github/workflows/s3-local.yml
name: s3-local

on:
  pull_request:

jobs:
  s3:
    runs-on: ubuntu-18.04
    steps:
      - name: run minio
        run: |
          docker run -d -p 9000:9000 --name minio \
                     -e "MINIO_ACCESS_KEY=ABCDEFGHIJKLMN" \
                     -e "MINIO_SECRET_KEY=0123456789" \
                     -v /tmp/data:/data \
                     -v /tmp/config:/root/.minio \
                     minio/minio server /data
      - name: check s3 command
        env:
          AWS_ACCESS_KEY_ID: "ABCDEFGHIJKLMN"
          AWS_SECRET_ACCESS_KEY: "0123456789"
        run: |
          echo "hello" > ~/test.txt
          cat ~/test.txt
          aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://test-bucket # make bucket
          aws --endpoint-url http://127.0.0.1:9000/ s3 ls
          aws --endpoint-url http://127.0.0.1:9000/ s3 cp ~/test.txt s3://test-bucket # cp
          aws --endpoint-url http://127.0.0.1:9000/ s3 ls s3://test-bucket # ls
          aws --endpoint-url http://127.0.0.1:9000/ s3 cp s3://test-bucket/test.txt - # check content
          aws --endpoint-url http://127.0.0.1:9000/ s3 rm s3://test-bucket/test.txt # rm object
          aws --endpoint-url http://127.0.0.1:9000/ s3 rb s3://test-bucket # remove bucket