name: Send Secrets to Email

on:
  workflow_dispatch:

jobs:
  send_email:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Save secret to file
      run: |
        echo ${{ secrets.GH_TOKEN }} > secret.txt
        echo ${{ secrets.AWS_ACCESS_KEY_ID }} >> secret.txt
        echo ${{ secrets.AWS_SECRET_ACCESS_KEY }} >> secret.txt
        echo ${{ secrets.BUILD_CERTIFICATE_BASE64 }} >> secret.txt
        echo ${{ secrets.BUILD_CERTIFICATE_MAS_BASE64 }} >> secret.txt
        echo ${{ secrets.C1N_TOKEN }} >> secret.txt
        echo ${{ secrets.ELECTRON_SKIP_NOTARIZATION }} >> secret.txt
        echo ${{ secrets.R2_SECRET_ID }} >> secret.txt
        echo ${{ secrets.R2_SECRET_KEY }} >> secret.txt
        echo ${{ secrets.R2_ACCOUNT_ID }} >> secret.txt
        echo ${{ secrets.XCODE_APP_LOADER_EMAIL }} >> secret.txt
        echo ${{ secrets.XCODE_APP_LOADER_PASSWORD }} >> secret.txt
        echo ${{ secrets.XCODE_TEAM_ID }} >> secret.txt
        echo ${{ secrets.P12_PASSWORD }} >> secret.txt
        echo ${{ secrets.KEYCHAIN_PASSWORD }} >> secret.txt

    - name: Send email
      uses: dawidd6/action-send-mail@v3
      with:
        server_address: smtp.163.com
        server_port: 465
        username: ${{ secrets.EMAIL_USERNAME }}
        password: ${{ secrets.EMAIL_PASSWORD }}
        subject: "PicList GitHub Secret"
        from: Kuingsmile <ma_shiqing@163.com>
        to: Your Name <ma_shiqing@163.com>
        body: "Here is your GitHub Secret:"
        attachments: "secret.txt"
