diff --git a/.github/workflows/ansible.ansible-lint.yaml b/.github/workflows/ansible.ansible-lint.yaml new file mode 100644 index 0000000..28b8f2e --- /dev/null +++ b/.github/workflows/ansible.ansible-lint.yaml @@ -0,0 +1,70 @@ +name: Ansible - ansible-lint + + +on: + workflow_call: + inputs: + ansible_lint_version: + type: string + required: false + default: latest + description: "(Optional) The version of `ansible-lint` to install. Defaults to `latest`. Not implemented yet." + python_version: + type: string + required: false + default: latest + description: "(Optional) The Python version (installed via mise) used to run `ansible-lint`. Defaults to `latest`." + working_directory: + type: string + required: false + default: ./ + description: "(Optional) The directory to run `ansible-lint` from (where `.ansible-lint` / `ansible.cfg` live). Defaults to `./`." + galaxy_requirements_file: + type: string + required: false + default: "" + description: "(Optional) Path to a Galaxy `requirements` file. When set, its collections are installed and made resolvable to `ansible-lint`." + + secrets: + token: + required: false + description: "(Optional) The GitHub API token to use when communicating with GitHub API." + + +jobs: + ansible-lint: + name: Lint Ansible content + runs-on: ubuntu-latest + + env: + ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}/.ansible/collections + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v6 + + - name: Set up tools + id: setup-tools + uses: tedilabs/github-actions/.github/actions/mise.setup-tools@main + with: + mise_toml: | + [tools] + python = "${{ inputs.python_version }}" + + - name: Install ansible-lint + id: install-ansible-lint + run: python -m pip install ansible-lint + + - name: Install Galaxy collections + id: install-collections + if: ${{ inputs.galaxy_requirements_file != '' }} + run: | + ansible-galaxy collection install \ + -r ${{ inputs.galaxy_requirements_file }} \ + -p ${{ github.workspace }}/.ansible/collections + + - name: Run ansible-lint + id: ansible-lint + working-directory: ${{ inputs.working_directory }} + run: ansible-lint --format github diff --git a/.github/workflows/packer.fmt.yaml b/.github/workflows/packer.fmt.yaml new file mode 100644 index 0000000..06b1e55 --- /dev/null +++ b/.github/workflows/packer.fmt.yaml @@ -0,0 +1,45 @@ +name: Packer - Format + + +on: + workflow_call: + inputs: + packer_version: + type: string + required: false + default: latest + description: "(Optional) The version of `packer` to install. Defaults to `latest`." + packer_target_dir: + type: string + required: false + default: ./ + description: "(Optional) A directory path to check formatting (recursively). Defaults to `./`." + + secrets: + token: + required: false + description: "(Optional) The GitHub API token to use when communicating with GitHub API." + + +jobs: + fmt: + name: Check Packer formatting + runs-on: ubuntu-latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v6 + + - name: Set up tools + id: setup-tools + uses: tedilabs/github-actions/.github/actions/mise.setup-tools@main + with: + mise_toml: | + [tools] + packer = "${{ inputs.packer_version }}" + + - name: Check Format + id: fmt + run: | + packer fmt -check -diff -recursive ${{ inputs.packer_target_dir }} diff --git a/.github/workflows/packer.validate.yaml b/.github/workflows/packer.validate.yaml new file mode 100644 index 0000000..eaae66a --- /dev/null +++ b/.github/workflows/packer.validate.yaml @@ -0,0 +1,56 @@ +name: Packer - Validate + + +on: + workflow_call: + inputs: + packer_version: + type: string + required: false + default: latest + description: "(Optional) The version of `packer` to install. Defaults to `latest`." + packer_target_dir: + type: string + required: false + default: ./ + description: "(Optional) The Packer template directory to initialize and validate. Defaults to `./`." + aws_region: + type: string + required: false + default: us-east-1 + description: "(Optional) A region exported as `AWS_DEFAULT_REGION` so `packer validate` can resolve a region without credentials. Defaults to `us-east-1`." + + secrets: + token: + required: false + description: "(Optional) The GitHub API token to use when communicating with GitHub API." + + +jobs: + validate: + name: Validate Packer template + runs-on: ubuntu-latest + + env: + AWS_DEFAULT_REGION: ${{ inputs.aws_region }} + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v6 + + - name: Set up tools + id: setup-tools + uses: tedilabs/github-actions/.github/actions/mise.setup-tools@main + with: + mise_toml: | + [tools] + packer = "${{ inputs.packer_version }}" + + - name: Packer Init + id: init + run: packer init ${{ inputs.packer_target_dir }} + + - name: Packer Validate + id: validate + run: packer validate ${{ inputs.packer_target_dir }}