Adding date variable to commit message

Hello!

I’m trying to have yesterday’s date dynamically inserted in commit messages when my action runs.

I’ve gotten to this so far:

jobs:
  updateData:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    
    - uses: actions/setup-python@v2
      with:
        python-version: '3.7'
        
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install setuptools>=42.0.0
        pip install -r requirements.txt
    - name: Generate file
      run: python app.py

    - name: Get yesterday's date
      id: ydate
      run: echo "set-output name=ydate::$(date -d "yesterday 22:0" +'%Y-%m-%d')"
    
    - name: Update data
      run: |
        git config --global user.name 'username'
        git config --global user.email 'email'
        git add *.csv
        git commit -am 'Added data for ${{ steps.ydate.outputs.ydate }}'
        git push

The Get yesterday’s date step runs properly and outputs the date but the commit message ends up being 'Added data for '.

How does one integrate/concatenate the output with the rest of the commit message string?

Thanks!

I wonder if the problem might be the apostrophe s in the step name? Maybe that’s not being parsed well since it isn’t quoted?

Haven’t tested, but plausible.

Try echoing the value before the commit? (Just as a troubleshooting idea).

Hi @fredericharnois,

Glad to see you in Github Community Forum!

This is due to you lost “::” for set-output command, fixed as below:

    - name: Get yesterday's date
      id: ydate
      run: |
        echo "::set-output name=ydate::$(date -d "yesterday 22:0" +'%Y-%m-%d')"  # add :: before set-ouput

Thanks

Nice catch, I totally overlooked that. :man_facepalming:

Thank you so much to you both @weide-zhou @kingthorin! It really was just that.