Skip to content

Commit

Permalink
chore: adiciona suporte ao Cosign
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliagranato committed Aug 26, 2024
1 parent 3639eec commit eed6f31
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/chainguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
security-events: write

steps:
# Passo 1: Checkout do código
# Checkout do código
- name: Checkout code
uses: actions/checkout@v3

# Passo 2: Configurar Docker Buildx
# Configurar Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Passo 3: Instalar Melange
# Instalar Melange
- name: Install Melange
run: |
wget https://github.com/chainguard-dev/melange/releases/download/v0.11.2/melange_0.11.2_linux_386.tar.gz
Expand All @@ -32,7 +32,7 @@ jobs:
sudo mv melange /usr/local/bin/
melange version
# Passo 4: Instalar APKO
# Instalar APKO
- name: Install APKO
run: |
wget https://github.com/chainguard-dev/apko/releases/download/v0.14.7/apko_0.14.7_linux_386.tar.gz
Expand All @@ -41,71 +41,83 @@ jobs:
sudo mv apko /usr/local/bin/
apko version
# Passo 5: Gerar chaves com Melange
# Instalar Cosign
- name: Instalar Cosign
uses: sigstore/cosign-installer@v3.6.0

# Gerar chaves com Melange
- name: Generate keys with Melange
run: |
cd chainguard
melange keygen
# Passo 6: Construir pacotes com Melange
# Construir pacotes com Melange
- name: Build packages with Melange
run: |
cd chainguard
melange build melange.yaml --runner docker --signing-key melange.rsa --arch amd64
# Passo 7: Construir imagem de container com APKO
# Construir imagem de container com APKO
- name: Build container image with APKO
run: |
cd chainguard
apko build apko.yaml senhas senhas.tar -k melange.rsa.pub --arch amd64
# Login no DockerHub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Load da imagem Docker
- name: Load Docker image
run: |
cd chainguard
docker load < senhas.tar
docker images
# Extrair metadados (tags, labels) para Docker
- name: Extrair metadados (tags, labels) para Docker
id: meta
uses: docker/metadata-action@v5
with:
images: nataliagranato/senhas

# Gerar nome único para a tag
- name: Gerar nome único para a tag
id: generate-tag
run: |
# Obtém os primeiros 5 dígitos do hash do commit e a data
SHORT_HASH=$(git log -1 --pretty=format:%h | cut -c1-5)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
echo "tag=${SHORT_HASH}-${TIMESTAMP}" >> $GITHUB_ENV
echo "::set-output name=tag::${SHORT_HASH}-${TIMESTAMP}"
echo "::set-output name=tag::${SHORT_HASH}-${TIMESTAMP}"
# Fazer push da imagem Docker
- name: Push Docker image
id: push-docker-image
run: |
docker tag senhas:latest-amd64 ${{ secrets.DOCKER_USERNAME }}/senhas:${{ steps.generate-tag.outputs.tag }}
docker push ${{ secrets.DOCKER_USERNAME }}/senhas:${{ steps.generate-tag.outputs.tag }}
# Scan de segurança com Aqua Security Trivy
- name: Aqua Security Trivy
uses: aquasecurity/trivy-action@0.24.0
with:
image-ref: nataliagranato/senhas:${{ steps.generate-tag.outputs.tag }}
format: 'sarif'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
output: 'trivy-results.sarif'


# Envio dos resultados do Trivy para a aba de Segurança do GitHub
- name: Fazer upload dos resultados do Trivy para a aba de Segurança do GitHub
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'


# Assinar imagem com o Cosign
- name: Assinar imagem com uma chave
run: |
images=""
Expand Down

0 comments on commit eed6f31

Please sign in to comment.