Fix boot #164
Workflow file for this run
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: Run pre-commit | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: setup setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10.14' | |
- name: Install terraform_fmt | |
run: | | |
function getLatestVersion() { | |
LATEST_ARR=($(wget -q -O- https://api.github.com/repos/hashicorp/terraform/releases 2> /dev/null | awk '/tag_name/ { print $2 }' | cut -d '"' -f 2 | cut -d 'v' -f 2)) | |
for ver in "${LATEST_ARR[@]}"; do | |
if [[ ! $ver =~ beta ]] && [[ ! $ver =~ rc ]] && [[ ! $ver =~ alpha ]]; then | |
LATEST="$ver" | |
break | |
fi | |
done | |
echo -n "$LATEST" | |
} | |
mkdir -p ./terraform | |
cd ./terraform | |
echo "Install Terraform" | |
VERSION=$(getLatestVersion) | |
cd ~ | |
wget "https://releases.hashicorp.com/terraform/"$VERSION"/terraform_"$VERSION"_linux_amd64.zip" | |
unzip -o "terraform_"$VERSION"_linux_amd64.zip" | |
sudo install terraform /usr/local/bin/ | |
cd .. | |
rm -rf ./terraform | |
terraform version | |
echo "Done Installing Terraform" | |
- name: Install terraform doc | |
env: | |
TFDOCS_VERSION: 0.18.0 | |
INSTALL_PATH: /usr/local/bin | |
run: | | |
set -euo pipefail | |
mkdir -p ./terraform-docs | |
cd ./terraform-docs | |
platform=$(uname -s | tr '[:upper:]' '[:lower:]') | |
arch=$(uname -m) | |
wget --no-check-certificate https://github.com/terraform-docs/terraform-docs/releases/download/v${TFDOCS_VERSION}/terraform-docs-v${TFDOCS_VERSION}-${platform}-amd64.tar.gz | |
ls -la terraform-docs-v${TFDOCS_VERSION}-${platform}-amd64.tar.gz | |
tar --version | |
tar -xvf terraform-docs-v${TFDOCS_VERSION}-${platform}-amd64.tar.gz | |
chmod +x terraform-docs | |
mv ./terraform-docs ${INSTALL_PATH}/terraform-docs | |
cd .. | |
rm -rf ./terraform-docs | |
terraform-docs version | |
- name: Install tflint | |
env: | |
TFLINT_VERSION: 0.52.0 | |
INSTALL_PATH: /usr/local/bin | |
run: | | |
set -euo pipefail | |
mkdir -p ./tflint | |
cd ./tflint | |
platform=$(uname -s | tr '[:upper:]' '[:lower:]') | |
arch=$(uname -m) | |
if [ "$arch" == "x86_64" ]; then | |
arch="amd64" | |
fi | |
filename="tflint_${platform}_${arch}.zip" | |
echo $filename | |
wget --no-check-certificate "https://github.com/terraform-linters/tflint/releases/download/v${TFLINT_VERSION}/${filename}" | |
ls -lah $filename | |
sudo unzip $filename -d "${INSTALL_PATH}" | |
cd .. | |
rm -rf ./tflint | |
tflint --version | |
- name: Install Trivy | |
env: | |
TRIVY_VERSION: 0.53.0 | |
INSTALL_PATH: /usr/local/bin | |
run: | | |
mkdir -p ./trivy | |
cd ./trivy | |
set -euo pipefail | |
wget --no-check-certificate "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" | |
ls -la trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz | |
tar -xvf trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz | |
mv ./trivy ${INSTALL_PATH}/trivy | |
cd .. | |
rm -rf ./trivy | |
trivy --version | |
trivy server --download-db-only | |
- name: Install tfupdate | |
env: | |
TFUPDATE_VERSION: 0.8.2 | |
INSTALL_PATH: /usr/local/bin | |
REPO: "minamijoyo/tfupdate" | |
run: | | |
set -euo pipefail | |
mkdir -p ./tfupdate | |
cd ./tfupdate | |
wget --no-check-certificate "https://github.com/${REPO}/releases/download/v${TFUPDATE_VERSION}/tfupdate_${TFUPDATE_VERSION}_linux_amd64.tar.gz" | |
tar -xvf tfupdate_${TFUPDATE_VERSION}_linux_amd64.tar.gz | |
mv ./tfupdate ${INSTALL_PATH}/tfupdate | |
cd .. | |
rm -rf ./tfupdate | |
tfupdate --version | |
- name: Install pre-commit framework | |
env: | |
PRE_COMMIT_VERSION: 3.7.1 | |
run: | | |
pip install pre-commit==${PRE_COMMIT_VERSION} | |
pre-commit --version | |
- name: Run pre-commit | |
run: pre-commit run --all-files --verbose --show-diff-on-failure --color=auto |