Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
aws-region: us-west-2

- name: Build, tag, and push the image to Amazon ECR
id: build-image
Expand All @@ -54,3 +54,14 @@ jobs:
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"

- name: Packer build
uses: ExitoLab/packer_build_action_aws@v0.2.10
with:
templateFile: 'packer/config.json'
workingDir: '.'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
LEC_VERSION: ${{ steps.version.outputs.new_tag }}
47 changes: 47 additions & 0 deletions packer/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"aws_region": "us-west-2",
"lec_version": "{{env `LEC_VERSION`}}"
},
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"ami_name": "log-export-container@{{user `lec_version`}}",
"instance_type": "t2.micro",
"region": "{{user `aws_region`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-focal-20.04-amd64-server*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"ssh_username": "ubuntu",
"type": "amazon-ebs"
}
],
"provisioners": [
{
"type": "file",
"source": "lec-playbook.yml",
"destination": "/home/ubuntu/lec-playbook.yml"
},
{
"type": "file",
"source": "env-file.example",
"destination": "/home/ubuntu/env-file"
},
{
"execute_command": "echo 'ubuntu' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"scripts": [
"packer/install-ansible-and-run-playbook.sh"
],
"type": "shell"
}
]
}
6 changes: 6 additions & 0 deletions packer/install-ansible-and-run-playbook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo rm -r /var/lib/apt/lists/*
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
sudo ansible-playbook /home/ubuntu/lec-playbook.yml