Skip to content

Commit

Permalink
Merge pull request #1 from jpradoar/development
Browse files Browse the repository at this point in the history
fix: add vars in trivy
  • Loading branch information
jpradoar authored Nov 10, 2024
2 parents aebc137 + 361f2c5 commit bd3ac48
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions .github/workflows/webserver-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
SLACK_MSG_COLOR: '#0092ff'
BUILD_CONTEXT: './06-webserver'
VULN_SEVERITY: 'CRITICAL'
VULN_TYPE: 'os,library'
VULN_TIMEOUT_SCAN: '2m0s'
VULN_OUTPUT_TYPE: 'table'
VULN_OUTPUT_FILE: 'mqtt-webserver_vuln_scan.txt'
Expand All @@ -36,26 +37,18 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Generate new version with Semantic-Version
id: nversion
- name: Show last version of docker-hub image
id: last_version_remote_file
run: |
commit_message=$(git log --format=%B -n 1 ${{ github.sha }})
version=$(curl -s "https://hub.docker.com/v2/repositories/jpradoar/${{ env.REPO_APP }}/tags/?page_size=2" | jq -r '.results[].name'|sort -M|grep -v latest)
X=$(echo $version|cut -d. -f1)
Y=$(echo $version|cut -d. -f2)
Z=$(echo $version|cut -d. -f3)
custom_version=$(echo $X.$Y.$Z)
if [[ $commit_message == *major:* ]]; then
echo "version actual:" $version
NuevaVersion=$(($X+1)).0.0
elif [[ $commit_message == *minor:* ]]; then
NuevaVersion=$X.$(($Y+1)).0
elif [[ $commit_message == *patch:* ]]; then
NuevaVersion=$X.$Y.$(($Z+1))
else
NuevaVersion="latest"
fi
echo "NEW_VERSION=$NuevaVersion " >> "$GITHUB_OUTPUT"
LastVersion=$(curl -s "https://hub.docker.com/v2/repositories/jpradoar/${{ env.REPO_APP }}/tags/?page_size=2" | jq -r '.results[].name'|sort -M|grep -v latest|tail -1)
echo "LAST_VERSION=$LastVersion " >> "$GITHUB_OUTPUT"
- name: Generate new version with semantic version
id: nversion
uses: jpradoar/[email protected]
with:
COMMIT_MSG: ${{ github.event.head_commit.message }}
VERSION: ${{ steps.last_version_remote_file.outputs.LAST_VERSION }}

- name: Build and push
uses: docker/build-push-action@v4
Expand All @@ -68,19 +61,19 @@ jobs:
id: vulnscan
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_APP }}:${{ steps.nversion.outputs.NEW_VERSION }}'
image-ref: 'jpradoar/${{ env.REPO_APP }}:${{ steps.nversion.outputs.NEW_VERSION }}'
format: ${{ env.VULN_FORMAT }}
vuln-type: 'os,library'
vuln-type: ${{ env.VULN_TYPE }}
severity: ${{ env.VULN_SEVERITY }}
timeout: ${{ env.VULN_TIMEOUT_SCAN }}
output: vuln_scans/${{ env.VULN_OUTPUT_FILE }}
#exit-code: '1'

# - uses: EndBug/add-and-commit@v9
# with:
# message: 'AutoCommit: Add table file'
# add: ./vuln_scans/${{ env.VULN_OUTPUT_FILE }}
# committer_name: ${{ env.COMMITER_NAME }}
- uses: EndBug/add-and-commit@v9
with:
message: 'AutoCommit: Add table file'
add: ./vuln_scans/${{ env.VULN_OUTPUT_FILE }}
committer_name: ${{ env.COMMITER_NAME }}

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
Expand Down

0 comments on commit bd3ac48

Please sign in to comment.