diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..d21c216 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,114 @@ +name: CI +on: + push: + branches: + - "**" + tags: + - "!**" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + - name: Ensure requirements are installed + run: pip install -r requirements.txt + - name: Lint with ansible-lint + run: ansible-lint -c ".ansible-lint" + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + - name: Lint with yamllint + run: yamllint . + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + molecule: + name: Molecule Test + runs-on: ubuntu-latest + needs: lint + strategy: + fail-fast: true + matrix: + os: [almalinux8, almalinux9] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Ensure requirements are installed + run: pip install -r requirements.txt + + - name: Run Molecule tests. + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + MOLECULE_DISTRO: ${{ matrix.os }} + release: + runs-on: ubuntu-latest + needs: + - lint + - molecule + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + - name: Install gitea provider for Go Semantic Release + run: | + mkdir -p .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/ && \ + wget https://github.com/cybercinch/go-semantic-release-provider-gitea/releases/download/v${GITEA_PROVIDER_VER}/go-semantic-release-provider-gitea_v${GITEA_PROVIDER_VER}_linux_amd64 \ + -O .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/gitea && \ + chmod a+x .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/gitea + env: + GITEA_PROVIDER_VER: 1.0.11 + - run: | + echo "github repo: ${GITHUB_REPOSITORY}" + echo "env vars: $(env)" + - uses: go-semantic-release/action@v1 + with: + custom-arguments: --provider=gitea + env: + GITEA_TOKEN: ${{ secrets.G_TOKEN }} + GITEA_HOST: ${{ secrets.G_SERVER_URL}} + notify: + runs-on: ubuntu-latest + needs: + - lint + - molecule + - release + steps: + - name: ntfy-success-notifications + uses: niniyas/ntfy-action@master + if: success() + with: + url: '${{ vars.NTFY_URL }}' + title: Workflow success - ansible-role-common + topic: 'ci-status' + priority: 4 + tags: +1,partying_face,action,successfully,completed + details: Workflow has been successfully completed! + icon: 'https://styles.redditmedia.com/t5_32uhe/styles/communityIcon_xnt6chtnr2j21.png' + image: true + + - name: ntfy-failed-notifications + uses: niniyas/ntfy-action@master + if: failure() + with: + url: '${{ vars.NTFY_URL }}' + title: Workflow failed - ansible-role-common + topic: 'ci-status' + priority: 5 + tags: -1,skull,action,failed + details: Workflow has failed! + actions: 'default' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index d3194f6..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: Molecule Test -on: - push: - branches: - - 'main' - tags-ignore: - - 'v*' -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - max-parallel: 4 - matrix: - molecule_distro: ['centos7', 'centos8', 'almalinux8' ] - env: - ANSIBLE_CALLBACK_WHITELIST: profile_tasks - - steps: - - name: Checout Source - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --upgrade molecule['docker'] docker 'ansible==2.9.19' - - name: Test with molecule - run: | - molecule test --all - env: - MOLECULE_DISTRO: ${{ matrix.molecule_distro }} - EPEL_MIRROR_URL: https://pproxy.guise.net.nz/epel diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml deleted file mode 100644 index 2116b21..0000000 --- a/.github/workflows/on-tag.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Create a new release on github -on: - push: - tags: - - '*' -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Create GitHub release - uses: Roang-zero1/github-create-release-action@master - with: - version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ - update_existing: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6646d6f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +ansible-core<2.17 +ansible-compat >= 4 +molecule[docker]== 24.2.1 +ansible-lint==24.2.2 +yamllint==1.35.1 +passlib==1.7.4 \ No newline at end of file