|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + pages: write |
| 13 | + id-token: write |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: "pages" |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + Bot-pyLint: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + defaults: |
| 23 | + run: |
| 24 | + working-directory: "ansible-sdv-pipeline" |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - name: Set up Python 3.x |
| 29 | + uses: actions/setup-python@v3 |
| 30 | + with: |
| 31 | + python-version: 3.x |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install pylint flake8 ansible==10.2.0 |
| 36 | + pip install -r requirements.txt |
| 37 | + - name: Analysing the code with pylint |
| 38 | + run: | |
| 39 | + pylint $(git ls-files '*.py') --fail-under 5 --fail-on F,E,W,C,R |
| 40 | + - name: Checking code styling |
| 41 | + run: | |
| 42 | + flake8 . |
| 43 | + # |
| 44 | + Bot-ansible-lint: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + defaults: |
| 47 | + run: |
| 48 | + working-directory: "ansible-sdv-pipeline" |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - name: Set up Python 3.x |
| 53 | + uses: actions/setup-python@v3 |
| 54 | + with: |
| 55 | + python-version: 3.x |
| 56 | + - name: Install Ansible-lint |
| 57 | + run: | |
| 58 | + python -m pip install --upgrade pip |
| 59 | + pip install ansible-lint |
| 60 | + - name: Running Ansible-lint |
| 61 | + run: ansible-lint ./* |
| 62 | + # |
| 63 | + Bot-test: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + - name: Use Node.js 18.x |
| 71 | + uses: actions/setup-node@v3 |
| 72 | + with: |
| 73 | + node-version: "18.x" |
| 74 | + cache: "npm" |
| 75 | + cache-dependency-path: "**/package-lock.json" |
| 76 | + - name: Installing dependencies |
| 77 | + run: npm ci |
| 78 | + - name: Linting the commit message |
| 79 | + run: npx commitlint -V --from=HEAD~1 |
| 80 | + - name: Linting the application code |
| 81 | + run: npm run lint-bot |
| 82 | + - name: Running unit tests |
| 83 | + run: npm run unit-test |
| 84 | + Docs-build: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + defaults: |
| 87 | + run: |
| 88 | + working-directory: "docs" |
| 89 | + |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - name: Use Node.js 18.x |
| 94 | + uses: actions/setup-node@v3 |
| 95 | + with: |
| 96 | + node-version: "18.x" |
| 97 | + cache: "npm" |
| 98 | + cache-dependency-path: "**/package-lock.json" |
| 99 | + |
| 100 | + - name: Installing dependencies |
| 101 | + run: npm ci |
| 102 | + |
| 103 | + - name: Linting the docs code |
| 104 | + run: npm run lint |
| 105 | + working-directory: "docs" |
| 106 | + |
| 107 | + - name: Setup Pages |
| 108 | + uses: actions/configure-pages@v4 |
| 109 | + with: |
| 110 | + static_site_generator: next |
| 111 | + |
| 112 | + - name: Building docs |
| 113 | + run: npm run build |
| 114 | + |
| 115 | + - name: Uploading artifacts |
| 116 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 117 | + uses: actions/upload-pages-artifact@v3 |
| 118 | + with: |
| 119 | + path: ./docs/out |
| 120 | + # |
| 121 | + Docs-deploy: |
| 122 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 123 | + environment: |
| 124 | + name: github-pages |
| 125 | + url: ${{ steps.deployment.outputs.page_url }} |
| 126 | + |
| 127 | + runs-on: ubuntu-latest |
| 128 | + defaults: |
| 129 | + run: |
| 130 | + working-directory: "docs" |
| 131 | + needs: Docs-build |
| 132 | + |
| 133 | + steps: |
| 134 | + - name: Publish to GitHub Pages |
| 135 | + id: deployment |
| 136 | + uses: actions/deploy-pages@v4 |
| 137 | + # |
| 138 | + Dependabot-merge: |
| 139 | + needs: [bot-pyLint, Bot-ansible-lint, Bot-test, Docs-build] |
| 140 | + runs-on: ubuntu-latest |
| 141 | + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'cicsdev/cics-security-sdv-samples' |
| 142 | + steps: |
| 143 | + - name: Dependabot metadata |
| 144 | + id: metadata |
| 145 | + uses: dependabot/fetch-metadata@v2 |
| 146 | + with: |
| 147 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 148 | + - name: Enable auto-merge for Dependabot PRs |
| 149 | + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' |
| 150 | + run: gh pr merge --auto --merge "$PR_URL" |
| 151 | + env: |
| 152 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 153 | + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
0 commit comments