Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wiki workflows #120

Merged
merged 1 commit into from
Jul 10, 2024
Merged
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
49 changes: 49 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Linting
on:
pull_request:
types: ['opened', 'synchronize']
merge_group:
workflow_dispatch:

concurrency:
group: linting-${{ github.event.pull_request.head.repo.full_name }}/${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
superlinter:
name: super linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
terraform_wrapper: false
- name: Run github/super-linter/slim
uses: github/super-linter/slim@v5
env:
# Lint all code
VALIDATE_ALL_CODEBASE: true
FILTER_REGEX_EXCLUDE: '.*tests/vendor/.*'
# Need to define main branch as default
# is set to master in super-linter
DEFAULT_BRANCH: main
# Enable setting the status of each individual linter
# run in the Checks section of a pull request
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The following linter types will be enabled:
VALIDATE_BASH: true
VALIDATE_BASH_EXEC: true
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_JSON: true
VALIDATE_MARKDOWN: true
# VALIDATE_TERRAFORM_TERRASCAN: true # disabled for now as does not support TF 1.3 optional(type, default)
VALIDATE_TERRAFORM_TFLINT: true
VALIDATE_YAML: true
# VALIDATE_GO: true # Disabled because it down not work :(
# Additional settings:
# If a shell script is not executable, the bash-exec
# linter will report an error when set to true
ERROR_ON_MISSING_EXEC_BIT: true
65 changes: 65 additions & 0 deletions .github/workflows/wiki-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Docs/Wiki Sync

permissions:
contents: write

# yamllint disable-line rule:truthy
on:
release:
types: [published]
workflow_dispatch:

env:
wiki_source_repo: "${{ github.repository }}"
wiki_source_repo_dir: "${{ github.repository }}/docs/wiki"
wiki_target_repo: "${{ github.repository }}.wiki"
github_user_name: "github-actions"
github_email: "[email protected]"
github_commit_message: "GitHub Action syncing wiki from docs/wiki"

jobs:
sync-wiki:
name: Sync Wiki
if: github.repository == 'Azure/ALZ-PowerShell-Module' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout Source Repo
uses: actions/checkout@v3
with:
repository: ${{ env.wiki_source_repo }}
path: ${{ env.wiki_source_repo }}

- name: Checkout Wiki Repo
uses: actions/checkout@v3
with:
repository: ${{ env.wiki_target_repo }}
path: ${{ env.wiki_target_repo }}

- name: Configure Local Git
run: |
git config --global user.name "$github_user_name"
git config --global user.email "$github_email"
working-directory: ${{ env.GITHUB_WORKSPACE }}

- name: Sync docs/wiki Into Wiki Repo
run: |
rsync -avzr --delete --exclude='.git/' "$wiki_source_repo_dir/" "$wiki_target_repo"
working-directory: ${{ env.GITHUB_WORKSPACE }}

- name: Check for changes
id: git_status
run: |
mapfile -t "CHECK_GIT_STATUS" < <(git status -s)
printf "%s\n" "${CHECK_GIT_STATUS[@]}"
echo "changes=${#CHECK_GIT_STATUS[@]}" >> "$GITHUB_OUTPUT"
working-directory: ${{ env.wiki_target_repo }}

- name: Add files, commit and push into Wiki
if: steps.git_status.outputs.changes > 0
run: |
echo "Pushing changes to origin..."
git add .
git commit -m "$github_commit_message [$GITHUB_ACTOR/${GITHUB_SHA::8}]"
git push --set-upstream "https://[email protected]/$wiki_target_repo.git" master
working-directory: ${{ env.wiki_target_repo }}
Loading