Created
October 13, 2020 04:38
-
-
Save marlluslustosa/e958d02606117d61fbe7c0f5b88b972b to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Workflow - scan agendado | |
on: | |
schedule: | |
# toda segunda-feira às 5 horas da matina! | |
- cron: '0 5 * * 1' | |
env: | |
# Variavel de ambiente vista para qualquer job | |
# nome da imagem - altere para o nome correto | |
IMAGE_NAME: nome-imagem | |
jobs: | |
# procura vulnerabilidades na imagem gerada no passo anterior | |
scan: | |
# somente faz scan se o job anterior concluiu com êxito | |
needs: push | |
name: Vulnerability Scan | |
runs-on: ubuntu-18.04 | |
steps: | |
- name: Pull docker image | |
id: pullimage | |
run: | | |
docker pull ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# setar variavel local para repassar ao trivy | |
echo ::set-output name=nome_imagem::$IMAGE_NAME | |
# cria issue no repositório, se encontrar vulnerabilidades | |
- uses: homoluctus/[email protected] | |
id: trivy | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# imagem que foi 'pusheada' no job anterior | |
image: ghcr.io/${{ github.repository_owner }}/${{ steps.pullimage.outputs.nome_imagem }} | |
issue_title: Alerta de segurança | |
# comenta issue, citando reponsavel para resolucao | |
- name: responder issue | |
env: | |
REPO: ${{ github.event.repository.name }} | |
OWNER: ${{ github.event.repository.owner.login }} | |
ISSUE_NUMBER: ${{ steps.trivy.outputs.issue_number }} | |
run: | | |
# se variavel de retorno html_url (do step trivy) contiver algo, isso quer dizer que foi criada uma issue, entao, comente-a. | |
if [ ! -z "${{ steps.trivy.outputs.html_url }}" ]; then | |
curl -s -X POST https://api.github.com/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/comments -d '{"body":"Ei, @marlluslustosa, pode dar uma olhada nessa issue?"}' -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment