name: Nightly

on:
  push:
    branches:
      - 'main'

jobs:
  build:
    name: Publish escript for every merge to main
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - uses: erlef/setup-beam@v1
      with:
          otp-version: '26'
    - name: Compile
      run: ./bootstrap
    - name: CT tests
      run: ./rebar3 ct

    - 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: us-east-1

    - name: Copy rebar3 escript to S3
      run: |
        aws s3 cp ./rebar3 s3://rebar3-nightly
