Skip to content

ID-4208: Remove contextpath on local-docker for proxy-no. (#13) #6

ID-4208: Remove contextpath on local-docker for proxy-no. (#13)

ID-4208: Remove contextpath on local-docker for proxy-no. (#13) #6

name: Build/publish Docker image
on:
push:
branches: [ main ]
paths-ignore:
- 'src/test/**'
- 'docker-compose.yaml'
- '*.md'
- 'LICENSE'
jobs:
build-image:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ secrets.REGISTRY_URL }}/eidas-demo-country-ca
DOCKLE_HOST: "unix:///var/run/docker.sock"
outputs:
image-version: ${{ steps.set-outputs.outputs.image-version }}
image-digest: ${{ steps.set-outputs.outputs.image-digest }}
steps:
- name: Set imagetag as env variable
run: echo "IMAGETAG=$(date +'%Y-%m-%d-%H%M')-${GITHUB_SHA::8}" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- name: Build the tagged Docker image
run: docker build --tag ${{env.IMAGE_NAME}}:${{env.IMAGETAG}} --file docker/CA.Dockerfile .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # pin@v0.19.0
with:
image-ref: ${{env.IMAGE_NAME}}:${{env.IMAGETAG}}
exit-code: "1"
severity: "CRITICAL,HIGH"
- uses: anchore/sbom-action@v0
with:
image: ${{env.IMAGE_NAME}}:${{env.IMAGETAG}}
artifact-name: sbom-${{ github.event.repository.name }}-${{env.IMAGETAG}}.spdx
- name: "Login to Azure Container registery"
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: docker push ${{env.IMAGE_NAME}}:${{env.IMAGETAG}}
- run: echo "IMAGE_DIGEST=$(docker inspect --format='{{.RepoDigests}}' ${{env.IMAGE_NAME}}:${{env.IMAGETAG}}|cut -d '@' -f 2|cut -d ']' -f 1)" >> "$GITHUB_ENV"
- name: Find jira-id
id: regex-find-jira-id
env:
GIT_MSG: ${{ github.event.head_commit.message }}
run: |
JIID=$(echo "$GIT_MSG" | head -1 |
sed -E 's/^([a-zA-Z]{2,6}\-[0-9]+).+/\1/')
echo "JIRAID=$JIID" >> "$GITHUB_OUTPUT"
- id: output-jira-id
if: ${{ steps.regex-find-jira-id.outputs.JIRAID != '' }}
run: echo "JIRA_ID=${{ steps.regex-find-jira-id.outputs.JIRAID }}" >> "$GITHUB_ENV"
- uses: octokit/request-action@v2.x
id: get_labels
with:
route: GET /repos/${{ github.repository }}/commits/${{ github.sha }}/pulls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "PR_LABELS=${{ join(fromJSON(steps.get_labels.outputs.data)[0].labels.*.name) }}" >> "$GITHUB_ENV"
echo "PR_NUMBER=${{ fromJson(steps.get_labels.outputs.data)[0].number }}" >> "$GITHUB_ENV"
- id: check_dependabot
run: echo "DEPENDABOT=${{ contains(env.PR_LABELS, 'dependencies') }}" >> "$GITHUB_ENV"
- id: output-dependabot
if: ${{ steps.regex-find-jira-id.outputs.match == '' && env.DEPENDABOT == 'true' }}
run: echo "JIRA_ID=Dependabot" >> "$GITHUB_ENV"
- name: Set Outputs
id: set-outputs
run: |
{
echo "image-version=${{ env.IMAGETAG }}"
echo "image-digest=${{ env.IMAGE_DIGEST }}"
} >> "$GITHUB_OUTPUT"
call-update-image:
uses: felleslosninger/github-workflows/.github/workflows/ci-call-update-image.yml@main
needs: build-image
with:
application-name: eidas-demo-country-ca
deployment-environment: systest
image-digest: ${{ needs.build-image.outputs.image-digest }}
image-name: eidas-demo-country-ca
image-version: ${{ needs.build-image.outputs.image-version }}
kubernetes-repo: idporten-cd
product-name: eidas
secrets: inherit