You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some code to get the current commit hash and time in my build process. Specifically, I am using SvelteKit and I fetch the commit details in the vite.config.js file.
For a while, this has been silently broken on my site and I have not been able to reproduce the issue locally. After adding some logging to my build process I found that the git commands to fetch these details do not execute successfully because the Azure/static-web-apps-deploy@v1 is getting mounted in the build container (which seems to mess up directory ownership) and the directory is not marked as a safe directory in git.
status: 'rejected',
reason: Error: Command failed: git describe --tags || git rev-parse --short HEAD
fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:
git config --global --add safe.directory /github/workspace
I think an easy way to fix it would be for the container to run git config --global --add safe.directory /github/workspace before actually running the build.
Github workflow file:
name: Azure Static Web Apps CI/CD
on:
workflow_dispatch:
push:
branches:
- master
paths:
- frontend/**
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ICY_BUSH_07607F803 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "frontend" # App source code path
api_location: "frontend/build/server" # Api source code path - optional
output_location: "build/static"
skip_app_build: false
###### End of Repository/Build Configurations ######
To Reproduce
Steps to reproduce the behavior:
Create a sveltekit project
Add replace the contents of the vite.config.js file with the following:
Additional context
See actions/runner-images#6775 for more details, it appears to be a result of a CVE in git.
The text was updated successfully, but these errors were encountered:
biltongza
changed the title
Cannot run git commands in CI due to dubious ownership
Cannot run git commands in CI due to dubious ownership in repository
Sep 11, 2023
I have run into the same issue. I am deploying the Hugo app cstate (https://github.com/cstate/cstate), which gets the last-modified info from git history for displaying incident history.
As @biltongza says, since the container is mounting the git directory from outside, it really needs to run the git command to trust the directory as the first step in its containerized workflow.
I forgot I logged this issue, but I also found a workaround. It turns out that you can specify pre build commands via an environment variable. You can add this to your workflow:
Describe the bug
I have some code to get the current commit hash and time in my build process. Specifically, I am using SvelteKit and I fetch the commit details in the
vite.config.js
file.For a while, this has been silently broken on my site and I have not been able to reproduce the issue locally. After adding some logging to my build process I found that the git commands to fetch these details do not execute successfully because the
Azure/static-web-apps-deploy@v1
is getting mounted in the build container (which seems to mess up directory ownership) and the directory is not marked as a safe directory in git.I think an easy way to fix it would be for the container to run
git config --global --add safe.directory /github/workspace
before actually running the build.Github workflow file:
To Reproduce
Steps to reproduce the behavior:
vite.config.js
file with the following:My personal repo experiencing this issue: https://github.com/biltongza/ldam.co.za
Affected CI run: https://github.com/biltongza/ldam.co.za/actions/runs/6145310617/job/16672439301
Expected behavior
Git commands run normally.
Additional context
See actions/runner-images#6775 for more details, it appears to be a result of a CVE in git.
The text was updated successfully, but these errors were encountered: