I have followed existing online documentations to come up with this code that save the variable file_size
in the step bellow, however it's always blank, even when there are files avaliable, what am I doing wrong?
- name: Get modified files
id: files
uses: umani/[email protected]
with:
repo-token: ${{ github.token }}
pattern: '^src.*\.(py)$'
result-encoding: 'string'
- name: Check files size
id: file_check
run: |
echo ::set-output name=file_size::$(printf "%s" "${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}" | wc -m)
echo 'MESSAGE<<EOF' >> $GITHUB_ENV
echo "No valid file found, skipped" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Lint with pylint
if: steps.vars.file_check.file_size > 1
This is the run result:
The bash command is correct as I tried it online:
So that just mean the variable isn't saved in github action, how come?
You need to pass the value to $GITHUB_ENV
like so:
echo "file_size="$(printf "%s" "${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}" | wc -m) >> $GITHUB_ENV
Otherwise the value will not persist.