Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions workflow env.REPORT_DATE ✅ #5

Open
xgqfrms opened this issue Sep 6, 2023 · 0 comments
Open

GitHub Actions workflow env.REPORT_DATE ✅ #5

xgqfrms opened this issue Sep 6, 2023 · 0 comments

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented Sep 6, 2023

GitHub Actions workflow env.REPORT_DATE ✅

image

https://github.com/xgqfrms/weather-email-action/actions/runs/6094061170/job/16534840070

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

name: Weather_Email_Bot

# Controls when the action will run. 
on:
  # Triggers the workflow on push events but only for the main branch
  push:
    branches: [ main ]
#   schedule:
#     - cron: '00 00 * * *'

  # 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"
  hello-job:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Hello, world!
  # weather job
  weather-email-bot:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout codes'
        uses: actions/checkout@v1
      # 自动获取天气信息
      - name: 'Get Weather'
        run: bash ./weather.sh
      # 自定义 env, $GITHUB_ENV => ${{env.REPORT_DATE}}
      - name: 'Get Date'
        run: echo "REPORT_DATE=$(TZ=':Asia/Shanghai' date '+%Y-%m-%d %T')" >> $GITHUB_ENV
      # 自动发送邮件
      - name: 'Send mail'
        uses: dawidd6/action-send-mail@master
        with:
          server_address: smtp.163.com
          server_port: 465
          # username: ${{ secrets.MAIL_USERNAME }}
          # password: ${{ secrets.MAIL_PASSWORD }}
          username: ${{ secrets.MAILUSERNAME }}
          password: ${{ secrets.MAILPASSWORD }}
          # fix secrets name bug ✅
          subject: Shanghai Weather Report (${{env.REPORT_DATE}})
          body: file://result.html
          to: ${{ secrets.MAILTO }}
          from: GitHub Actions
          content_type: text/html

      # test
      - name: 'Print Name bug'
        run: |
          echo "secrets.MAILUSERNAME = " ${{ secrets.MAILUSERNAME }}
      - name: 'Print GITHUB_ENV env ✅'
        run: |
          echo "❓ env.REPORT_DATE = " ${{env.REPORT_DATE}}

xgqfrms added a commit that referenced this issue Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant