【问题标题】:Github Action - use Variable in the script [duplicate]Github Action - 在脚本中使用变量 [重复]
【发布时间】:2020-04-21 14:24:18
【问题描述】:

使用 Github 操作 (https://github.com/features/actions) 来备份文件,我需要创建一个以今天的日期/时间命名的新文件夹。

name: Backup Database

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Backup
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.KEY }}
          port: 22
          script: |
            DATE=${{ NEW DATE }} # Need to create a variable with date/time
            mkdir backup_${{ DATE }} # Create a new folder with the date/time

【问题讨论】:

标签: variables yaml github-actions


【解决方案1】:

该用户发现了一个 hack 来创建使用 bash 命令输出生成的变量:

用他的话来说:

I found a way to hack this limitation. 
Write your VAR on disk (the CI system disk), 
then cat $my_var to use your VAR in every step you need 

https://github.com/actions/starter-workflows/issues/68#issuecomment-524937002

【讨论】:

猜你喜欢
  • 2020-05-09
  • 2016-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-10
  • 1970-01-01
  • 2011-03-13
  • 2021-06-19
相关资源
最近更新 更多