Skip to content

New namespace #361

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

New namespace #361

wants to merge 18 commits into from

Conversation

jjstratton
Copy link
Collaborator

These are all the pipelines for the new namespace - they will delete the old pipelines so only merge when we are ready to do that

Copy link

Comment on lines +21 to +101
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}-client:dev .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}-client:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}-client:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag ccversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/ccversion: .*/ccversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} clamavclient image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we will add a permissions block at the root of the workflow. This block will define the minimal permissions required for the workflow to function correctly. Based on the actions used in the workflow, the following permissions are needed:

  • contents: write for committing and pushing changes to the repository.
  • packages: write for pushing Docker images to the Artifactory registry.

The permissions block will be added after the name field in the workflow file.


Suggested changeset 1
.github/workflows/build-push-clamav-client.yaml

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-push-clamav-client.yaml b/.github/workflows/build-push-clamav-client.yaml
--- a/.github/workflows/build-push-clamav-client.yaml
+++ b/.github/workflows/build-push-clamav-client.yaml
@@ -1,2 +1,5 @@
 name: clamav-client-build-and-push-dev
+permissions:
+  contents: write
+  packages: write
 
EOF
@@ -1,2 +1,5 @@
name: clamav-client-build-and-push-dev
permissions:
contents: write
packages: write

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +23 to +103
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev -f form_handler/Dockerfile .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag fhversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/fhversion: .*/fhversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} formhandler image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the least privileges required for the workflow to function correctly. Based on the operations performed in the workflow, the following permissions are recommended:

  • contents: read for reading repository contents.
  • pull-requests: write for updating Helm values and committing changes.

The permissions block can be added at the root level of the workflow to apply to all jobs or within the build job to limit permissions to that specific job.


Suggested changeset 1
.github/workflows/build-push-form-handler.yaml

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-push-form-handler.yaml b/.github/workflows/build-push-form-handler.yaml
--- a/.github/workflows/build-push-form-handler.yaml
+++ b/.github/workflows/build-push-form-handler.yaml
@@ -13,2 +13,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 env:
EOF
@@ -13,2 +13,6 @@

permissions:
contents: read
pull-requests: write

env:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +23 to +103
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev -f ingestor/Dockerfile .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag iversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/iversion: .*/iversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} ingestor image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the operations performed in the workflow, the following permissions are recommended:

  • contents: read for accessing repository files.
  • pull-requests: write for updating Helm values and committing changes.

The permissions block can be added at the root level of the workflow to apply to all jobs or within the build job to limit permissions to that specific job.

Suggested changeset 1
.github/workflows/build-push-ingestor.yaml

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-push-ingestor.yaml b/.github/workflows/build-push-ingestor.yaml
--- a/.github/workflows/build-push-ingestor.yaml
+++ b/.github/workflows/build-push-ingestor.yaml
@@ -13,2 +13,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 env:
EOF
@@ -13,2 +13,6 @@

permissions:
contents: read
pull-requests: write

env:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +21 to +101
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag mnversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/mnversion: .*/mnversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} mailnet image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the operations performed in the workflow, the following permissions are likely required:

  • contents: read for reading repository contents.
  • pull-requests: write for updating Helm values and committing changes.

The permissions block can be added at the root level of the workflow to apply to all jobs, or it can be added specifically to the build job. In this case, adding it at the root level is recommended for simplicity.


Suggested changeset 1
.github/workflows/build-push-mail-net.yaml

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-push-mail-net.yaml b/.github/workflows/build-push-mail-net.yaml
--- a/.github/workflows/build-push-mail-net.yaml
+++ b/.github/workflows/build-push-mail-net.yaml
@@ -11,2 +11,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 env:
EOF
@@ -11,2 +11,6 @@

permissions:
contents: read
pull-requests: write

env:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +23 to +103
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev -f paybc_api/Dockerfile .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag pbcversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/pbcversion: .*/pbcversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} paybc image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the least privileges required for the workflow to function correctly. Based on the operations performed in the workflow, the following permissions are likely required:

  • contents: read for accessing repository files.
  • pull-requests: write for updating Helm values and committing changes.

The permissions block can be added at the root level of the workflow to apply to all jobs or within the build job to limit permissions to that specific job.

Suggested changeset 1
.github/workflows/build-push-paybc.yaml

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-push-paybc.yaml b/.github/workflows/build-push-paybc.yaml
--- a/.github/workflows/build-push-paybc.yaml
+++ b/.github/workflows/build-push-paybc.yaml
@@ -13,2 +13,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 env:
EOF
@@ -13,2 +13,6 @@

permissions:
contents: read
pull-requests: write

env:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +23 to +103
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev -f validator/Dockerfile .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag vversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/vversion: .*/vversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} validator image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we will add a permissions block at the root of the workflow file. This block will explicitly define the minimal permissions required for the workflow to function. Based on the workflow's operations, it needs read access to the repository contents and write access to pull requests. We will set contents: read and pull-requests: write as the permissions.


Suggested changeset 1
.github/workflows/build-push-validator.yaml

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-push-validator.yaml b/.github/workflows/build-push-validator.yaml
--- a/.github/workflows/build-push-validator.yaml
+++ b/.github/workflows/build-push-validator.yaml
@@ -2,2 +2,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 on:
EOF
@@ -2,2 +2,6 @@

permissions:
contents: read
pull-requests: write

on:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +21 to +101
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Dev Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag wfversion: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/wfversion: .*/wfversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} webform image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, add a permissions block at the root level of the workflow file to explicitly define the least privileges required for the workflow. Since the workflow involves operations like reading repository contents and pushing changes, the permissions should be limited to contents: read and pull-requests: write. This ensures that the GITHUB_TOKEN has only the necessary access.

The permissions block should be added after the name field and before the on field in the workflow file. No additional imports or dependencies are required for this fix.


Suggested changeset 1
.github/workflows/build-push-web-form.yaml

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-push-web-form.yaml b/.github/workflows/build-push-web-form.yaml
--- a/.github/workflows/build-push-web-form.yaml
+++ b/.github/workflows/build-push-web-form.yaml
@@ -1,2 +1,5 @@
 name: web-form-build-and-push-dev
+permissions:
+  contents: read
+  pull-requests: write
 
EOF
@@ -1,2 +1,5 @@
name: web-form-build-and-push-dev
permissions:
contents: read
pull-requests: write

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +21 to +57
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev -f writer/Dockerfile .

- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: image
image-ref: artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev
format: 'table'
ignore-unfixed: true
limit-severities-for-sarif: true
severity: HIGH,CRITICAL

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the workflow's operations, it appears that only contents: read is necessary, as the workflow does not modify repository contents or interact with issues or pull requests.

The permissions block can be added at the root level of the workflow to apply to all jobs. This ensures that the GITHUB_TOKEN has restricted access throughout the workflow.


Suggested changeset 1
.github/workflows/build-push-writer.yaml

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-push-writer.yaml b/.github/workflows/build-push-writer.yaml
--- a/.github/workflows/build-push-writer.yaml
+++ b/.github/workflows/build-push-writer.yaml
@@ -13,2 +13,5 @@
 
+permissions:
+  contents: read
+
 env:
EOF
@@ -13,2 +13,5 @@

permissions:
contents: read

env:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +27 to +123
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set Conditions
run: |
if [[ "${{ env.IMAGE_NAME }}" == "clamav-client" ]]; then
echo "IMAGE_PREFIX=cc" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "form-handler" ]]; then
echo "IMAGE_PREFIX=fh" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "ingestor" ]]; then
echo "IMAGE_PREFIX=i" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "mail-net" ]]; then
echo "IMAGE_PREFIX=mn" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "paybc" ]]; then
echo "IMAGE_PREFIX=pbc" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "validator" ]]; then
echo "IMAGE_PREFIX=v" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "web-form" ]]; then
echo "IMAGE_PREFIX=wf" >> $GITHUB_ENV
else
echo "Unknown application: ${{ env.IMAGE_NAME }}"
fi

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Backup Prod Image
run: |
docker pull artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod
docker tag artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod-backup
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod-backup

- name: Docker Pull to Artifactory
run: |
docker pull artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:test

- name: Docker Tag and Push to Artifactory
run: |
docker tag artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:test artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:prod

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Test Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag ${{ env.IMAGE_PREFIX }}version: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/${{ env.IMAGE_PREFIX }}version: .*/${{ env.IMAGE_PREFIX }}version: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we will add a permissions block at the root of the workflow file. This block will define the minimal permissions required for the workflow to function correctly. Based on the workflow's operations, it needs read access to contents for cloning the repository and write access to contents for committing and pushing changes. Additionally, it may require packages: write for interacting with Docker images in Artifactory.

The permissions block will be added after the name field and before the on field in the workflow file.


Suggested changeset 1
.github/workflows/push-to-prod.yaml

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/push-to-prod.yaml b/.github/workflows/push-to-prod.yaml
--- a/.github/workflows/push-to-prod.yaml
+++ b/.github/workflows/push-to-prod.yaml
@@ -1,2 +1,5 @@
 name: Push to Test 
+permissions:
+  contents: write
+  packages: write
 
EOF
@@ -1,2 +1,5 @@
name: Push to Test
permissions:
contents: write
packages: write

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +27 to +117
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set Conditions
run: |
if [[ "${{ env.IMAGE_NAME }}" == "clamav-client" ]]; then
echo "IMAGE_PREFIX=cc" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "form-handler" ]]; then
echo "IMAGE_PREFIX=fh" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "ingestor" ]]; then
echo "IMAGE_PREFIX=i" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "mail-net" ]]; then
echo "IMAGE_PREFIX=mn" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "paybc" ]]; then
echo "IMAGE_PREFIX=pbc" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "validator" ]]; then
echo "IMAGE_PREFIX=v" >> $GITHUB_ENV
elif [[ "${{ env.IMAGE_NAME }}" == "web-form" ]]; then
echo "IMAGE_PREFIX=wf" >> $GITHUB_ENV
else
echo "Unknown application: ${{ env.IMAGE_NAME }}"
fi

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"

- name: Docker Pull to Artifactory
run: |
docker pull artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev

- name: Docker Tag and Push to Artifactory
run: |
docker tag artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:dev artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:test
docker push artifacts.developer.gov.bc.ca/${{env.REPO_KEY}}-${{env.IMAGE_NAME}}/${{env.IMAGE_NAME}}:test

- name: Set GitOps SSH Key
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.RSBC_SSH_KEY }}

- name: Update Helm Test Values and Commit
id: helm
run: |

echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "

# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "RSBC-APR GitHub Actions"
git clone -b ${{ env.BRANCH_NAME }} --single-branch git@github.com:bcgov-c/tenant-gitops-f0392a.git

# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test

cd tenant-gitops-f0392a/charts

# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag ${{ env.IMAGE_PREFIX }}version: to ${{ steps.short_sha.outputs.SHORT_SHA }}"

sed -i "s/${{ env.IMAGE_PREFIX }}version: .*/${{ env.IMAGE_PREFIX }}version: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml

git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart

cd gitops

helm dependency build

git add .

git commit -m "Update ${{ env.BRANCH_NAME }} image tag"

# pull any changes
git pull origin ${{ env.BRANCH_NAME }}
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

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: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, add a permissions block to the root of the workflow file. This block will explicitly define the permissions for the GITHUB_TOKEN, limiting its access to the minimum required for the workflow's operations. Based on the workflow's functionality, the contents: read permission is sufficient, as the workflow does not require write access to repository contents.

The permissions block should be added at the top level of the workflow file, ensuring it applies to all jobs in the workflow. This change will enhance security by restricting the GITHUB_TOKEN permissions.


Suggested changeset 1
.github/workflows/push-to-test.yaml

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/push-to-test.yaml b/.github/workflows/push-to-test.yaml
--- a/.github/workflows/push-to-test.yaml
+++ b/.github/workflows/push-to-test.yaml
@@ -2,2 +2,5 @@
 
+permissions:
+  contents: read
+
 on:
EOF
@@ -2,2 +2,5 @@

permissions:
contents: read

on:
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Collaborator

@shaunmillargov shaunmillargov left a comment

Choose a reason for hiding this comment

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

Thanks Jessica

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

Successfully merging this pull request may close these issues.

2 participants