Repository navigation
Add build workflow for metering-test-adapter image #171
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: Build metering-test-adapter image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - 'osac-metering/metering-service/**' | ||
| - '!osac-metering/metering-service/**/*.md' | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - 'osac-metering/v*' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: osac-project/metering-test-adapter | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Log into registry ${{ env.REGISTRY }} | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Compute release version | ||
| if: startsWith(github.ref, 'refs/tags/osac-metering/') | ||
| run: | | ||
| version="${GITHUB_REF_NAME#osac-metering/}" | ||
| semver_re='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*)|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(\.((0|[1-9][0-9]*)|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*)?$' | ||
| if ! [[ "${version}" =~ ${semver_re} ]]; then | ||
| echo "::error::Tag '${GITHUB_REF_NAME}' is not a valid semver release tag" | ||
| exit 1 | ||
| fi | ||
| core="${version%%-*}" | ||
| echo "RELEASE_VERSION=${version}" >> "$GITHUB_ENV" | ||
| echo "RELEASE_MAJOR_MINOR=${core%.*}" >> "$GITHUB_ENV" | ||
| echo "RELEASE_MAJOR=${core%%.*}" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=raw,value=${{ env.RELEASE_VERSION }},enable=${{ env.RELEASE_VERSION != '' }} | ||
| type=raw,value=${{ env.RELEASE_MAJOR_MINOR }},enable=${{ env.RELEASE_VERSION != '' }} | ||
| type=raw,value=${{ env.RELEASE_MAJOR }},enable=${{ env.RELEASE_VERSION != '' }} | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=sha | ||
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: osac-metering/metering-service | ||
| file: osac-metering/metering-service/Containerfile.test-adapter | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
|
Comment on lines
+70
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== workflow header and relevant sections =="
cat -n .github/workflows/build-metering-test-adapter-image.yaml | sed -n '1,140p'
echo
echo "== occurrences of github-token permissions, id-token, cosign/Sigstore, docker/build-push and push outputs =="
rg -n "permissions:|id-token:|GITHUB_TOKEN|cosign|sigstore|docker/build-push-action|docker/build-push-action@|build:|outputs:|digest|ghcr|push:" .github/workflows/build-metering-test-adapter-image.yamlRepository: osac-project/osac Length of output: 3815 Security Misconfiguration (CWE-345) Reachability: External Sign each published image digest. This workflow publishes GHCR images without a Sigstore or cosign signature. Add a push-only signing step for 🤖 Prompt for AI AgentsSource: Path instructions |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: osac-project/osac
Length of output: 242
🏁 Script executed:
Repository: osac-project/osac
Length of output: 3788
Sensitive Data Exposure (CWE-522): Insufficiently Protected Credentials
Disable checkout credential persistence.
actions/checkout@v7storesGITHUB_TOKENin local Git config by default. No later step performs Git operations; registry push credentials come from the separate login step, so no other credential is required. Setwith: persist-credentials: false.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 31-32: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Source: Linters/SAST tools