add Authorization to allowed headers #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Containerimage | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
workflow_dispatch: | |
jobs: | |
build-test-push: | |
runs-on: ubuntu-latest | |
env: | |
SECRET_JWT_HASH: ${{ secrets.SECRET_JWT_HASH }} | |
SECRET_DEFAULT_PW: ${{ secrets.SECRET_DEFAULT_PW }} | |
SECRET_ADMIN_NAME: ${{ secrets.SECRET_ADMIN_NAME }} | |
outputs: | |
branch_name: ${{ steps.branch.outputs.branch_name }} | |
commit_hash: ${{ steps.commit.outputs.commit_hash }} | |
steps: | |
- uses: actions/checkout@v3 | |
name: checkout | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Create Image | |
run: | | |
docker build -t gamertrack-war . | |
- name: Run integrationTests | |
run: | | |
docker run -d --name gamertrack-test-container -p 8080:8080 -e SECRET_JWT_HASH=${{ secrets.SECRET_JWT_HASH }} -e SECRET_DEFAULT_PW=${{ secrets.SECRET_DEFAULT_PW }} -e SECRET_ADMIN_NAME=${{ secrets.SECRET_ADMIN_NAME }} gamertrack-war:latest | |
until curl -s http://localhost:8080/gepardec-gamertrack/api/v1/health | grep -q "running"; do | |
echo "Waiting for the Application..." | |
sleep 2 | |
done | |
mvn verify -Prun-integrationtests | |
docker stop gamertrack-test-container | |
docker rm gamertrack-test-container | |
- name: Log in to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get branch name | |
id: branch | |
run: echo "branch_name=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- name: Get commit hash | |
id: commit | |
run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Build Docker Image and Push to GHCR | |
run: | | |
docker tag gamertrack-war:latest ghcr.io/gepardec/gepardec-gamertrack:${{ env.branch_name }}-${{ env.commit_hash }} | |
docker tag gamertrack-war:latest ghcr.io/gepardec/gepardec-gamertrack:latest | |
docker push ghcr.io/gepardec/gepardec-gamertrack:${{ env.branch_name }}-${{ env.commit_hash }} | |
docker push ghcr.io/gepardec/gepardec-gamertrack:latest | |
scan: | |
name: scanning | |
runs-on: ubuntu-latest | |
needs: build-test-push | |
steps: | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@0.29.0 | |
with: | |
image-ref: 'ghcr.io/gepardec/gepardec-gamertrack:latest' | |
format: 'sarif' | |
ignore-unfixed: true | |
scanners: 'vuln,secret,misconfig' | |
severity: 'CRITICAL,HIGH' | |
output: 'trivy-results.sarif' | |
- name: Upload Trivy scan results to GitHub Security tab | |
if: always() | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: 'trivy-results.sarif' | |
category: 'code' | |
wait-for-processing: true |