'Github Action - use Variable in the script [duplicate]

With Github Actions how to do a backup of a file?

I need to create a new folder named with the date/time of today.

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


Solution 1:[1]

This user found a hack to create vars that are generated with bash commands output.

In his words:

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

Reference: "How to define env variable?"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DᴀʀᴛʜVᴀᴅᴇʀ