Skip to content

Added github token secret #1

Added github token secret

Added github token secret #1

name: Nightly Build and Test
on:
workflow_call:
secrets:
docker_username:
required: true
docker_password:
required: true
github_token:

Check failure on line 10 in .github/workflows/reusable_nightly.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/reusable_nightly.yaml

Invalid workflow file

secret name `github_token` within `workflow_call` can not be used since it would collide with system reserved name
required: true
inputs:
target_branches:
type: string
required: false
default: "master,main"
docker_image:
type: string
required: true
docker_tag:
type: string
required: false
default: "nightly"
build_command:
type: string
required: true
setup_qemu:
type: boolean
required: false
default: false
setup_buildx:
type: boolean
required: false
default: false
setup_go:
type: boolean
required: false
default: false
go_version_file:
type: string
required: false
default: "go.mod"
trivy_scan:
type: boolean
required: false
default: true
jobs:
nightly:
name: Nightly Build and Test
runs-on: ubuntu-latest
if: >
github.event_name == 'schedule' ||
contains(fromJSON(inputs.target_branches), github.ref_name)
env:
DOCKER_IMAGE: ${{ inputs.docker_image }}
DOCKER_TAG: ${{ inputs.docker_tag }}
TEST_IMAGE: ${{ inputs.docker_image }}:${{ inputs.docker_tag }}
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
- name: Set up QEMU
if: ${{ inputs.setup_qemu }}
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
if: ${{ inputs.setup_buildx }}
uses: docker/setup-buildx-action@v3
- name: Set up Go
if: ${{ inputs.setup_go }}
uses: actions/setup-go@v5
with:
go-version-file: ${{ inputs.go_version_file }}
- name: Build Image
run: ${{ inputs.build_command }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
shell: bash
continue-on-error: false
- name: Run Trivy to check Docker image for vulnerabilities
if: ${{ inputs.trivy_scan }}
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.TEST_IMAGE }}
format: 'table'
exit-code: '1' # Fail the workflow if vulnerabilities are found
ignore-unfixed: true
vuln-type: 'os,library'
severity: "CRITICAL,HIGH"
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db
notify-failure:
if: ${{ always() && failure() }}
needs: [nightly]
runs-on: ubuntu-latest
steps:
- name: Notify failure via Slack
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.CAOS_COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ inputs.docker_image }}`: [Nightly test/release failed](${{ github.server_url }}/${{ inputs.docker_image }}/actions/runs/${{ github.run_id }})."