Skip to content

Commit

Permalink
Use latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans-Chrstian committed Mar 18, 2024
1 parent 2c5228f commit 4dc10f3
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ env:
jobs:
ort:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: oss-review-toolkit/ort-ci-github-action@7f23c1f8d169dad430e41df223d3b8409c7a156e
Expand Down Expand Up @@ -47,35 +45,54 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Extract last tag
id: tag
run: |
IFS=',' read -ra TAGS <<< "${{ steps.meta.outputs.tags }}"
LAST_INDEX=$((${#TAGS[@]} - 1))
echo "last_tag=${TAGS[LAST_INDEX]}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}"
push: false
tags: ${{ steps.tag.outputs.last_tag }}
labels: ${{ steps.meta.outputs.labels }}
load: true

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ env.IMAGE_NAME }}:${{ github.sha }}"
image-ref: "${{ steps.tag.outputs.last_tag }}"
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL,HIGH"

deploy:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@85270a1854658d167ab239bce43949edb336fa7c
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: "${{ env.IMAGE_NAME }}:${{ github.sha }}"
images: "${{ steps.tag.outputs.last_tag }}"

0 comments on commit 4dc10f3

Please sign in to comment.