-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add config scanning to trivy (#143)
- Loading branch information
1 parent
5c8b983
commit 7645254
Showing
3 changed files
with
88 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Builds a Packer template. Reusable workflow that can be triggered manually or by the `packer-daily-builds.yml` workflow. Also triggeres on pull requests when packer templates are modified. | ||
|
||
name: Packer Build | ||
on: | ||
workflow_dispatch: # Manually trigger the workflow | ||
workflow_call: | ||
inputs: | ||
packer_template_file_name: | ||
description: 'Packer template file name' | ||
required: true | ||
type: string | ||
packer_template_dir: | ||
description: 'Packer template directory' | ||
required: true | ||
type: string | ||
packer_template_description: | ||
description: 'Packer template description' | ||
required: true | ||
type: string | ||
branch: | ||
description: 'Branch to checkout' | ||
required: true | ||
type: string | ||
default: main | ||
pull_request: | ||
paths: | ||
- 'assets/packer/**' | ||
permissions: | ||
id-token: write | ||
contents: read | ||
jobs: | ||
packer-ci: | ||
environment: aws-ci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
role-session-name: CGDToolkitGitHubActions | ||
- name: Checkout code | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
- name: Install AWS CLI | ||
run: | | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | ||
unzip awscliv2.zip | ||
sudo ./aws/install --update | ||
aws --version | ||
- name: Install Packer | ||
run: | | ||
PACKER_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version') | ||
wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip | ||
unzip packer_${PACKER_VERSION}_linux_amd64.zip | ||
mv packer /usr/local/bin | ||
rm packer_${PACKER_VERSION}_linux_amd64.zip | ||
- name: Packer Init and Validate | ||
working-directory: ./assets/packer/${{ inputs.packer_template_dir }} | ||
run: | | ||
echo "Validating Packer template: ${{ inputs.packer_template_description }} - ${{ inputs.packer_template_file_name }}" | ||
packer init ${{ inputs.packer_template_file_name }} | ||
cat > ci.pkrvars.hcl << EOF | ||
region = "${{ vars.AWS_REGION }}" | ||
vpc_id = "${{ secrets.AWS_VPC_ID_CI }}" | ||
subnet_id = "${{ secrets.AWS_SUBNET_ID_CI }}" | ||
public_key = <<PUBLIC_KEY | ||
${{ secrets.PACKER_CI_PUBLIC_KEY }} | ||
PUBLIC_KEY | ||
profile = "${{ secrets.AWS_PROFILE_CI }}" | ||
EOF | ||
packer validate -var-file=ci.pkrvars.hcl ${{ inputs.packer_template_file_name }} | ||
- name: Packer Build | ||
working-directory: ./assets/packer/${{ inputs.packer_template_dir }} | ||
run: | | ||
packer build -var-file=ci.pkrvars.hcl ${{ inputs.packer_template_file_name }} |
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
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