Skip to content

Commit

Permalink
revert back to old release
Browse files Browse the repository at this point in the history
  • Loading branch information
katarinagud committed Oct 22, 2024
1 parent 431c5f1 commit a020dd5
Showing 1 changed file with 96 additions and 74 deletions.
170 changes: 96 additions & 74 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'docker release'
name: 'dotnet build'

on:
push:
Expand All @@ -14,80 +14,102 @@ env:

jobs:
ci:
name: Release
name: 'build'
runs-on: ubuntu-latest
env:
RELEASE: ${{ github.event_name == 'push' && contains(inputs.branches || 'main,master', github.ref_name) }}

steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: mathieudutour/[email protected]
name: Calculate next version and create tag on GitHub
id: tag
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ${{ inputs.component && format('{0}/v',inputs.component) || 'v' }}
fetch_all_tags: true
release_branches: ${{ inputs.branches }}
dry_run: ${{ env.RELEASE != 'true' }}
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- name: Add private Nuget feed
run: dotnet nuget add source --username ${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} --password ${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} --store-password-in-clear-text --name "githubpackagesnuget" "https://nuget.pkg.github.com/RaaLabs/index.json"

- name: Install dependencies
run: dotnet restore --no-cache --verbosity normal
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test and report coverage
run: dotnet test --configuration Release --no-build /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/${{ env.COVERAGE_FOLDER }}/ /p:MergeWith=${{ github.workspace }}/${{ env.COVERAGE_FOLDER }}/coverage/ /p:CoverletOutputFormat=opencover

- name: 'ACR login'
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.RAAEDGE_LOGIN_SERVER }}
username: ${{ secrets.RAAEDGE_ACR_USERNAME }}
password: ${{ secrets.RAAEDGE_ACR_PASSWORD }}

- name: Establish context
id: context
uses: dolittle/establish-context-action@v2
with:
prerelease-branches: ${{ env.PRERELEASE_BRANCHES }}

- uses: hadolint/[email protected]
with:
dockerfile: ./Source/Dockerfile
failure-threshold: error

- name: Docker Build
uses: docker/build-push-action@v6
if: ${{ steps.context.outputs.should-publish == 'false' }}
with:
push: false
no-cache: true
context: .
file: ./Source/Dockerfile
build-args: |
CONFIGURATION=Release
secrets: |
NUGET_GITHUB_PACKAGES_USERNAME=${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }}
NUGET_GITHUB_PACKAGES_TOKEN=${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }}
platforms: linux/amd64
tags: ${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:latest

- name: Increment version
id: increment-version
if: ${{ steps.context.outputs.should-publish == 'true' }}
uses: dolittle/increment-version-action@v2
with:
version: ${{ steps.context.outputs.current-version }}
release-type: ${{ steps.context.outputs.release-type }}

- name: Docker push
uses: docker/build-push-action@v6
if: ${{ steps.context.outputs.should-publish == 'true' && inputs.IMAGE_NAME != '' }}
with:
push: true
no-cache: true
context: .
file: ./Source/Dockerfile
build-args: |
CONFIGURATION=Release
secrets: |
NUGET_GITHUB_PACKAGES_USERNAME=${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }}
NUGET_GITHUB_PACKAGES_TOKEN=${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }}
platforms: linux/amd64
tags: |
${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:${{ steps.increment-version.outputs.next-version }}
${{ env.DOCKER_IMAGE_REGISTRY_PATH }}:latest
- name: Docker logout
if: always()
run: |
docker logout ${{ secrets.RAAEDGE_LOGIN_SERVER }}
docker logout ${{ secrets.RAAEDGE_LOGIN_SERVER_2 }}
- name: Add private Nuget feed
run: dotnet nuget add source --username ${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} --password ${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} --store-password-in-clear-text --name "githubpackagesnuget" "https://nuget.pkg.github.com/RaaLabs/index.json"
- name: Create GitHub Release
uses: dolittle/github-release-action@v2
if: ${{ steps.context.outputs.should-publish == 'true' }}
with:
version: ${{ steps.increment-version.outputs.next-version }}
body: ${{ steps.context.outputs.pr-body }}

- name: Build Docker image
id: initial-build
uses: docker/build-push-action@v6
with:
push: false
no-cache: true
context: .
file: ${{ inputs.dockerfile || 'Source/Dockerfile' }}
load: true
platforms: linux/amd64
tags: image:local
build-args: |
BUILD_VERSION=${{ steps.tag.outputs.new_version }}
- name: Wiz scan the Docker Image for Vulnerabilities
id: wiz
env:
WIZ_CLIENT_ID: ${{ secrets.WIZ_CLIENT_ID }}
WIZ_CLIENT_SECRET: ${{ secrets.WIZ_CLIENT_SECRET }}
run: |
echo "Runs the Wiz Cli with a relaxed policy that shows only that have a fix available."
echo "Policy does not block the pipeline... yet!"
curl -o wizcli https://downloads.wiz.io/wizcli/latest/wizcli-linux-amd64 && chmod +x wizcli
./wizcli auth --id "$WIZ_CLIENT_ID" --secret "$WIZ_CLIENT_SECRET"
./wizcli docker scan --image ${{ steps.initial-build.outputs.imageid }} --policy "Relaxed Vulnerabilities Policy"
- name: Apply version tag to Docker images
id: references
run: |
echo ${{ github.event_name }}
IMAGES=$(tr "," "\n" <<<"${{ inputs.images }}" | sed "s/^[[:space:]]*//;s/[[:space:]]*$//")
echo -e "Images to tag:\n$IMAGES"
REFS=$(sed "s/$/:v${{ steps.tag.outputs.new_version }}/" <<<"$IMAGES" | paste -sd "," -)
echo -e "References: $REFS"
echo "tags=$REFS" >> $GITHUB_OUTPUT
- uses: azure/docker-login@v2
if: ${{ env.RELEASE == 'true' && contains(inputs.images, 'raaedge.azurecr.io') }}
with:
login-server: ${{ secrets.RAAEDGE_LOGIN_SERVER }}
username: ${{ secrets.RAAEDGE_ACR_USERNAME }}
password: ${{ secrets.RAAEDGE_ACR_PASSWORD }}
- name: Push Docker images
uses: docker/build-push-action@v6
if: ${{ env.RELEASE == 'true' }}
with:
push: true
context: .
file: ${{ inputs.dockerfile || 'Source/Dockerfile' }}
platforms: linux/amd64
tags: ${{ steps.references.outputs.tags }}
build-args: |
BUILD_VERSION=${{ steps.tag.outputs.new_version }}
- name: Make GitHub Release
if: ${{ env.RELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.tag.outputs.new_tag }} --target=${{ github.sha }} --title="${{ inputs.component && format('{0} - ',inputs.component) || '' }}v${{ steps.tag.outputs.new_version }}" --notes="${{ steps.tag.outputs.changelog }}"
outputs:
should-publish: ${{ steps.context.outputs.should-publish }}
current-version: ${{ steps.context.outputs.current-version }}
release-type: ${{ steps.context.outputs.release-type }}
version: ${{ steps.increment-version.outputs.next-version }}

0 comments on commit a020dd5

Please sign in to comment.