首页 > 其他分享 >GitHub workflows env All In One

GitHub workflows env All In One

时间:2023-09-07 19:56:04浏览次数:40  
标签:GitHub run env github GITHUB ENV workflows name

GitHub workflows env All In One

$GITHUB_ENV

docs

GITHUB_ENV environment file

# 把变量和值 `>>` 追加到 GITHUB_ENV 环境变量文件中
echo "{environment_variable_name}={value}" >> "$GITHUB_ENV"

steps:
  - name: Set the value
    id: step_one
    run: |
      echo "action_state=yellow" >> "$GITHUB_ENV"
  - name: Use the value
    id: step_two
    run: |
      printf '%s\n' "$action_state" # This will output 'yellow'

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable

env vs github.env

# ✅
${{ env.VARIABLE_NAME }}

# ✅ namespcae ❓
${{github.env.VARIABLE_NAME}}}

https://docs.github.com/en/actions/learn-github-actions/contexts#env-context

demos

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

# 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 08 * * *'
    # https://crontab.guru/#00_08_*_*_*
    # Runs at 08:00 on everyday
    # 分、时、日、月、周
    # https://www.cnblogs.com/xgqfrms/p/15384401.html
    # - cron: '00 08,20 * * *'

  # 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!
  # crawler job
  tesla-job:
    permissions:
      # Give the default GITHUB_TOKEN write permission to commit and push the
      # added or changed files to the repository.
      contents: write
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout codes'
        uses: actions/checkout@v3
      # 自定义 env, 并且 >> 追加到 GITHUB_ENV file 中 ✅
      # https://www.cnblogs.com/xgqfrms/p/17685587.html
      # 自定义 env, $GITHUB_ENV => ${{env.REPORT_DATE}} ✅
      # 自定义 env, $GITHUB_ENV => ${{github.env.REPORT_DATE}} ✅
      - name: 'set Date'
        run: echo "REPORT_DATE=$(TZ=':Asia/Shanghai' date '+%Y-%m-%d %T')" >> $GITHUB_ENV
      - name: 'print Date'
        run: echo ${{env.REPORT_DATE}}
        # vscode warning: Context access might be invalid: REPORT_DATE
        # https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
      - name: 'Get Date'
        run: echo ${{github.env.REPORT_DATE}}
        # vscode not warning
      - name: 'install package'
        run: npm i
      - name: 'begin'
        run: echo "crawling ...✅"
      - name: '自动爬取'
        run: node ./auto-update.js
      - name: 'end'
        run: echo "finshed 

标签:GitHub,run,env,github,GITHUB,ENV,workflows,name
From: https://www.cnblogs.com/xgqfrms/p/17685587.html

相关文章

  • github仓库包含子仓库,submodule设置
    1.进入主仓库创建一个lib用于存放子仓库,在cdlib,使用命令gitsubmoduleaddhttps://github.com/xxx.git可以将远端仓库的xxx克隆到当前文件夹,它会在主仓库生成一个.gitmodules文件,文件中包含[submodule"lib/xxx"]path=lib/xxxurl=https://github.com/xxx.git2.指定分支......
  • vcpkg 与 GitHub 依赖关系图集成
    我们很高兴与大家分享,vcpkg有一项实验性功能,可以向GitHub依赖关系图提供数据。我们正在积极开发此功能,并希望听到您的反馈。如果您对当前功能有任何想法或希望看到进一步的改进,请告诉我们。如果你对vcpkg支持的依赖关系图启用的任何GitHub特性有反馈,也请告诉我们,我们会确保Git......
  • Python-Virtualenv虚拟环境
    一.为何需要之前我们安装python第三方库时,都是直接通过pipinstallxx的方式进行安装的,这样会使第三方库直接安装到Python系统环境中,同时默认安装的都是最新版本的第三方库 这样安装会存在一个问题:如果用Django1.10.x开发了一个网站,同时有一个用Django0.9开发的旧项目需要......
  • Windows python版本管理工具pyenv
    windows下的python多环境pyenv-win搭建安装pyenv-win在PowerShell中安装建议使用管理员身份打开PowerShellInvoke-WebRequest-UseBasicParsing-Uri"https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1"-OutFile"./insta......
  • cross-env的理解
    1、什么是cross-env?它是运行跨平台设置和使用环境变量(Node中的环境变量)的脚本。2、cross-env的作用是什么?当我们使用NODE_ENV=production来设置环境变量的时候,大多数windows命令会提示将会阻塞或者异常,或者,windows不支持NODE_ENV=development的这样的设置方式,会报错。因......
  • 这可能是Github上最全面的Flutter教程,带你玩转Flutter
    Flutter是什么来头?Flutter是一款开源UI工具包,可利用单一代码库构建本地编译的移动、Web和桌面应用程序。Flutter由谷歌牵头开发,允许开发者构建出具有良好表现力、灵活设计、样式美观且运行迅速的应用程序。Flutter的核心语言为Dart,这是一种现代多范式语言,能够面向多个平台......
  • 基于Hugo的github个人博客的搭建
    一、前期准备以windows系统为例1.下载Git(https://git-scm.com/downloads)2.下载Hugo(https://github.com/gohugoio/hugo/releases)按照自己电脑下。3.设置环境变量:打开环境变量可以看到在系统变量有一个变量名为PATH的变量,直接点击然后编辑,把自己的git和hugo的位置添加进去。注意不是......
  • github 2FA验证
    github已经要求进行2FA验证,否则过期不能提交代码,github手机短信验证不支持中国号码,我按照下面文章介绍使用的是Chrome插件.https://zhuanlan.zhihu.com/p/615693483Chrome插件如果你不想用Python来自己计算,也可以使用一些第三方的插件。在这里我推荐一个叫做Authentic......
  • aarch64/arm_v8 环境下编译Arcade-Learning-Environment —— ale-py
       condainstallg++=12   cmake../-DCMAKE_BUILD_TYPE=Release-DPYTHON_INCLUDE_DIR=/home/share/xxx/home/software/anaconda3/include-DPYTHON_LIBRARY=/home/share/xxx/home/software/anaconda3/lib/libpython3.11.so-DPython3_EXECUTABLE=/home/share/x......
  • GitHub太慢
    1.修改本地hosts文件windows系统的hosts文件的位置如下:C:\Windows\System32\drivers\etc\hostsmac/linux系统的hosts文件的位置如下:/etc/hosts2.增加http://github.global.ssl.fastly.net和http://github.com的映射获取Github相关网站的ip访问https://www.ipaddress.com......