1

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
DᴀʀᴛʜVᴀᴅᴇʀ
  • 5,839
  • 15
  • 57
  • 101
Alan
  • 6,996
  • 2
  • 38
  • 60
  • 1
    Does this answer your question? [How do i set an env var with a bash expression in GitHub Actions?](https://stackoverflow.com/questions/57968497/how-do-i-set-an-env-var-with-a-bash-expression-in-github-actions) – Ramon Medeiros Jan 03 '20 at 00:43
  • yep it is! Thanks – Alan Jan 03 '20 at 00:47

1 Answers1

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?"

DᴀʀᴛʜVᴀᴅᴇʀ
  • 5,839
  • 15
  • 57
  • 101
Ramon Medeiros
  • 1,909
  • 1
  • 17
  • 35