Skip to content

Conversation

@jeremymoskowitz-netwrix
Copy link
Contributor

Jm test1 - Is dev any different?

jeremymoskowitz-netwrix and others added 2 commits July 31, 2025 09:48
…er docs

Changed "Windows 10" to "Windows" in remoteworkdelivery section to keep messaging simple and future-proof.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jeremymoskowitz-netwrix jeremymoskowitz-netwrix requested a review from a team as a code owner July 31, 2025 17:49
Comment on lines +21 to +36
determine-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- name: Determine environment
id: set-env
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "environment=${{ github.event.inputs.environment }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "environment=production" >> $GITHUB_OUTPUT
else
echo "environment=development" >> $GITHUB_OUTPUT
fi

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

Copilot Autofix

AI 2 months ago

The optimal fix is to add an explicit permissions: block restricting GITHUB_TOKEN scopes for the jobs that do not already have one, or at the workflow root to cover all jobs by default. For this workflow, the build job already has permissions: contents: read, but the determine-environment job is missing a permissions block. Since determine-environment only runs shell checks and sets an output, it should receive the absolute minimal permissions, typically contents: read. Optionally, if even read access is not needed, you may set all permissions to none, but contents: read is the standard minimal value. To ensure all future jobs are also limited by default, you may also add a workflow root-level permissions: block, but for this fix, we will add a minimal permissions block just for the flagged job.

Edit .github/workflows/build-and-deploy.yml and add

permissions:
  contents: read

under the determine-environment: job (line 21), e.g., right after runs-on: before outputs:.

Suggested changeset 1
.github/workflows/build-and-deploy.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -19,6 +19,8 @@
 jobs:
   determine-environment:
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
     outputs:
       environment: ${{ steps.set-env.outputs.environment }}
     steps:
EOF
@@ -19,6 +19,8 @@
jobs:
determine-environment:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +101 to +202
deploy:
runs-on: ubuntu-latest
needs: [build, determine-environment]
environment: ${{ needs.determine-environment.outputs.environment }}

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-output
path: build/

- name: Install azcopy
run: |
wget -O azcopy.tar.gz https://aka.ms/downloadazcopy-v10-linux
tar -xf azcopy.tar.gz --strip-components=1
sudo mv azcopy /usr/local/bin/
azcopy --version
- name: Install Azure CLI
run: |
if ! command -v az &> /dev/null; then
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
fi
az version
- name: Upload to Azure Blob Storage with AzCopy and comprehensive MIME types
run: |
echo "Deploying to ${{ needs.determine-environment.outputs.environment }} environment"
echo "Starting high-performance sync of changed files with proper MIME types..."
# Create SAS token for azcopy (using account key)
end_date=$(date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ')
sas_token=$(az storage container generate-sas \
--account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
--account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
--name '$web' \
--permissions dlrw \
--expiry $end_date \
--output tsv)
azcopy sync "./build/" \
"https://${{ secrets.STORAGE_ACCOUNT_NAME }}.blob.core.windows.net/\$web?$sas_token" \
--delete-destination=true \
--compare-hash=MD5 \
--log-level=INFO \
--cap-mbps=0 \
--block-size-mb=4
echo "Sync completed!"
- name: Set MIME types for all file types
run: |
echo "Setting MIME types for all file types..."
# Web files
echo "Setting MIME types for web files..."
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.css" --content-type "text/css" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.js" --content-type "application/javascript" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.mjs" --content-type "application/javascript" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.json" --content-type "application/json" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.html" --content-type "text/html" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.htm" --content-type "text/html" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.xml" --content-type "application/xml" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.txt" --content-type "text/plain" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
# Images
echo "Setting MIME types for images..."
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.png" --content-type "image/png" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.jpg" --content-type "image/jpeg" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.jpeg" --content-type "image/jpeg" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.gif" --content-type "image/gif" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.webp" --content-type "image/webp" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.svg" --content-type "image/svg+xml" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.ico" --content-type "image/x-icon" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
# Fonts
echo "Setting MIME types for fonts..."
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.woff" --content-type "font/woff" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.woff2" --content-type "font/woff2" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.ttf" --content-type "font/ttf" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
az storage blob update-batch --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} --source '$web' --pattern "*.otf" --content-type "font/otf" --if-unmodified-since "1970-01-01T00:00:00Z" --no-progress || true
echo "All MIME types set successfully!"
- name: Purge CDN endpoint (if configured)
run: |
if [[ -n "${{ secrets.CDN_ENDPOINT_NAME }}" ]] && [[ -n "${{ secrets.CDN_PROFILE_NAME }}" ]] && [[ -n "${{ secrets.CDN_RESOURCE_GROUP }}" ]]; then
echo "Note: CDN purge requires Azure login. Skipping CDN purge when using storage key authentication."
echo "To use CDN purge, you'll need to use Azure AD authentication or purge CDN manually."
else
echo "CDN configuration not found, skipping CDN purge."
fi
- name: Display deployment URL
run: |
echo "🚀 Deployment complete!"
echo "Environment: ${{ needs.determine-environment.outputs.environment }}"
echo "URL: https://${{ secrets.STORAGE_ACCOUNT_NAME }}.z13.web.core.windows.net"
if [[ -n "${{ secrets.CUSTOM_DOMAIN }}" ]]; then
echo "Custom Domain: ${{ secrets.CUSTOM_DOMAIN }}"
fi

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

Copilot Autofix

AI 2 months ago

General Fix:
Explicitly add a permissions: block to the top-level workflow or to the deploy job specification. The block should be as restrictive as possible, granting only the permissions required for the job (ideally, contents: read as a minimum starting point unless more are needed—none of the workflow’s steps in deploy appear to require even contents: read, so we could safely set it to none).

Best Single Fix:
Add a permissions: contents: read (or, more restrictively, permissions: none) block to the deploy job, just below runs-on: ubuntu-latest and above steps: (i.e. below line 101 and above line 105). This confines the GITHUB_TOKEN scope for this job, aligning it with least-privilege security best practices.

Exact Lines to Change:
Edit .github/workflows/build-and-deploy.yml:
Add the following after line 101 (or after line 104 if we want it at the same level as steps):

    permissions:
      contents: read

Alternatively, use permissions: {} or permissions: none if no permissions are needed (since the job only uses externally provided secrets and not the GITHUB_TOKEN).


Suggested changeset 1
.github/workflows/build-and-deploy.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -101,6 +101,8 @@
     runs-on: ubuntu-latest
     needs: [build, determine-environment]
     environment: ${{ needs.determine-environment.outputs.environment }}
+    permissions:
+      contents: read
 
     steps:
       - name: Download build artifact
EOF
@@ -101,6 +101,8 @@
runs-on: ubuntu-latest
needs: [build, determine-environment]
environment: ${{ needs.determine-environment.outputs.environment }}
permissions:
contents: read

steps:
- name: Download build artifact
Copilot is powered by AI and may make mistakes. Always verify output.
@jeremymoskowitz-netwrix jeremymoskowitz-netwrix requested a review from a team as a code owner August 27, 2025 21:01
Copy link
Contributor

@bturlea bturlea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rest of changes seem fine, but wondering why are we changing the workflow in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change intended on the build and deploy workflow?
Curious where this change is coming from or whether automatic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants