-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support hashing files outside the workspace directory #1035
Comments
I also would like to see this issue resolved. I am also having issues with caching with actions/setup-python#361 in a composite action. The maintainer of that action says that this bug can't be fixed until the issue in this repository is resolved. |
Same scenario for me: As a workaround I have to copy the scripts to the workspace directory. Not a super nice solution tho (there might already be a directory with the same name and so on..): - name: Set up Scripts
id: setup-scripts
shell: bash
run: |
SCRIPTS_PATH="$GITHUB_WORKSPACE/scripts"
cp -r "${{ github.action_path }}/../../scripts" "$SCRIPTS_PATH"
echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV
echo "::set-output name=scripts-path::$(echo $SCRIPTS_PATH)" |
Same problem here |
Perhaps I am missing something but this feature is already implemented? toolkit/packages/glob/src/internal-hash-files.ts Lines 9 to 13 in 45c49b0
Initially, when I used the function with just |
Huh, it looks like that changed since this was reported. The originally linked code was toolkit/packages/glob/src/internal-hash-files.ts Lines 16 to 19 in b463992
It seems that the equivalent check is still present toolkit/packages/glob/src/internal-hash-files.ts Lines 23 to 26 in 45c49b0
Though as @alexkuc notes there is now a way to set what the "workspace" is. This could potentially be used by other Actions to specify themselves as the "workspace", though seems perhaps an unintended consequence. (The change was in #1318). |
Curiously enough, there is no official documentation for |
Until hashFiles works outside of the workspace (in a composite), here's an example of the work-around I came up with: runs:
steps:
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.10'
update-environment: false
- uses: actions/github-script@v7
id: requirements-hash
with:
script: return require('fs').createReadStream(require('path').join(process.env.GITHUB_ACTION_PATH, 'requirements.txt')).pipe(require('crypto').createHash('sha1').setEncoding('hex'), 'finish').digest('hex')
result-encoding: string
- uses: actions/cache@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.requirements-hash.outputs.result }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
path: ${{ github.action_path }}/venv
- name: Setup python venv
shell: bash
run: |
${{ steps.setup-python.outputs.python-path }} -m venv "$GITHUB_ACTION_PATH/venv"
source "$GITHUB_ACTION_PATH/venv/bin/activate"
pip install -r "$GITHUB_ACTION_PATH/requirements.txt" |
Currently
hashFiles
ignores files outside the workspace. This means that it cannot be used to hash files which appear within an Action. In turn this means that packages such asactions/setup-python
cannot be used with files from the Action (see for example actions/setup-python#361), making them hard to use within composite Actions.It would be great if
hashFiles
could support these files as it would enable more powerful composite Actions.The text was updated successfully, but these errors were encountered: