Skip to content

Commit

Permalink
fix: Fetching algorithm updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Seha Artuç committed Jun 5, 2024
1 parent 303eb4e commit 794203b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/weekly_vuln_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ jobs:
fetch-and-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Docker
run: |
sudo service docker start
docker ps
run: sudo service docker start

- name: Login to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker info
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: List Docker Image Tags and Fetch Latest Two
run: |
Expand All @@ -37,8 +30,8 @@ jobs:
# Extract tags and creation dates, then sort by creation date
TAGS_WITH_DATES=$(echo "$RESPONSE" | jq -r '.[] | .metadata.container.tags[] as $tag | "\($tag) \(.created_at)"' | sort -k2 -r)
# Filter out the 'main' tag and get the latest two tags
LATEST_TAGS=$(echo "$TAGS_WITH_DATES" | awk '$1 != "main" {print $1}' | head -n 2 | tr '\n' ' ')
# Filter out the 'main' tag and get the latest tag from each of the latest two minor versions
LATEST_TAGS=$(echo "$TAGS_WITH_DATES" | awk '{split($1, a, "."); key=a[1] "." a[2]; if (!seen[key]++) print $0}' | head -n 2 | tr '\n' ' ')
# Print the results
echo "Tags fetched: $LATEST_TAGS"
Expand Down

0 comments on commit 794203b

Please sign in to comment.