GitHub Action: Self-Test #35
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: "GitHub Action: Self-Test" | |
# run once a week on Sunday at midnight | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
jobs: | |
test-action: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ matrix.environment }} | |
strategy: | |
matrix: | |
environment: [ | |
prod, | |
qa | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Test Action | |
id: test-action | |
uses: "./" | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: "us-west-2" | |
build: "amazon-ebs.ubuntu-example" | |
instance-type: "t3.micro" | |
packer-directory: "./example" | |
subnet-id: ${{ vars.SUBNET_ID }} | |
vpc-id: ${{ vars.VPC_ID }} | |
var-file: "./ubuntu-18.04.pkrvars.hcl" | |
- name: Clean Up AMIs | |
env: | |
AMI_ID: ${{ steps.test-action.outputs.ami-id }} | |
run: | | |
aws ec2 deregister-image \ | |
--image-id $AMI_ID \ | |
--region us-west-2 | |
test-packer: | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ matrix.environment }} | |
strategy: | |
matrix: | |
environment: [ | |
prod, | |
qa | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Packer | |
uses: hashicorp/[email protected] | |
with: | |
version: '1.7' | |
- name: Test Packer | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: "us-west-2" | |
SUBNET_ID: ${{ vars.SUBNET_ID }} | |
VPC_ID: ${{ vars.VPC_ID }} | |
working-directory: ./test | |
run: | | |
echo "Testing Packer..." | |
# Output the subnet and vpc ids | |
echo "Subnet ID: $PKR_VAR_subnet_id" | |
echo "VPC ID: $PKR_VAR_vpc_id" | |
go test -v -timeout 30m |