Skip to content

Add fixes for rpm and add a flag to disable log collection (#167) #15

Add fixes for rpm and add a flag to disable log collection (#167)

Add fixes for rpm and add a flag to disable log collection (#167) #15

name: Terraform - Docker
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for Docker image'
required: true
push:
paths-ignore:
- '.github/**'
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
push_to_docker_terraform_registry:
name: Build & Push Docker Image for Terraform
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.GHCR_TOKEN }}
ssh-key: ${{ secrets.CHECK_AGENT_ACCESS }}
submodules: 'recursive'
- name: Caching Go Modules and Build Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }} # Consists Github Personal Access Token
- name: Extract Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/middleware-labs/terraform-agent
- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: ./
file: Dockerfiles/DockerfileLinux
push: true
platforms: linux/amd64,linux/arm64
build-args: |
AGENT_VERSION=${{ env.RELEASE_VERSION }}
GITHUB_TOKEN=${{ secrets.GHCR_TOKEN }}
tags: |
ghcr.io/middleware-labs/terraform-agent
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.1.0
- name: Terraform Init
run: terraform init -var "do_token=${{ secrets.DIGITALOCEAN_TOKEN }}" -var "ssh_private_key=${{ secrets.TERRAFORM_SSH_PRIVATE_KEY }}" -var "ssh_public_key=${{ secrets.TERRAFORM_SSH_PUBLIC_KEY }}" -var "mw_api_key=${{ secrets.TERRAFORM_MW_API_KEY }}" -var "mw_target=${{ secrets.TERRAFORM_MW_TARGET }}"
- name: Terraform Apply
run: terraform apply -auto-approve -var "do_token=${{ secrets.DIGITALOCEAN_TOKEN }}" -var "ssh_private_key=${{ secrets.TERRAFORM_SSH_PRIVATE_KEY }}" -var "ssh_public_key=${{ secrets.TERRAFORM_SSH_PUBLIC_KEY }}" -var "mw_api_key=${{ secrets.TERRAFORM_MW_API_KEY }}" -var "mw_target=${{ secrets.TERRAFORM_MW_TARGET }}"
- name: Terraform Destroy
run: terraform destroy -auto-approve -var "do_token=${{ secrets.DIGITALOCEAN_TOKEN }}" -var "ssh_private_key=${{ secrets.TERRAFORM_SSH_PRIVATE_KEY }}" -var "ssh_public_key=${{ secrets.TERRAFORM_SSH_PUBLIC_KEY }}" -var "mw_api_key=${{ secrets.TERRAFORM_MW_API_KEY }}" -var "mw_target=${{ secrets.TERRAFORM_MW_TARGET }}"