Add lint workflow #4
Workflow file for this run
This file contains hidden or 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: Continuous integration | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| name: Test and lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php-versions: ['8.4'] | |
| steps: | |
| - name: Cancel Previous Runs | |
| uses: styfle/cancel-workflow-action@0.13.0 | |
| with: | |
| access_token: ${{ github.token }} | |
| - uses: actions/checkout@v6 | |
| - name: Install dependencies | |
| run: | | |
| composer validate | |
| composer install --prefer-dist --no-progress | |
| - name: Check PHP | |
| run: | | |
| composer fix | |
| composer test | |
| - name: Push the changes | |
| continue-on-error: true | |
| if: github.event_name == 'pull_request' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if ! git diff --exit-code --quiet; then | |
| git config --global user.name "github-actions" | |
| git config --global user.email "github-actions@users.noreply.github.com" | |
| git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
| git checkout -b ${GITHUB_HEAD_REF} | |
| git add . | |
| git commit -am "CI: lint code to standards" -m "Check commit and GitHub actions for more details" | |
| git pull origin ${GITHUB_HEAD_REF} --rebase | |
| git push --set-upstream origin ${GITHUB_HEAD_REF} | |
| else | |
| echo "No changes to commit" | |
| fi | |
| notify-irc: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: ${{ always() && github.repository_owner == 'miraheze' && ( github.ref == 'refs/heads/main' || github.event_name == 'pull_request' ) }} | |
| steps: | |
| - name: succeeded | |
| uses: technote-space/workflow-conclusion-action@v3 | |
| - uses: rectalogic/notify-irc@v2 | |
| if: env.WORKFLOW_CONCLUSION == 'success' | |
| with: | |
| channel: "#miraheze-tech-ops" | |
| server: "irc.libera.chat" | |
| nickname: miraheze-github | |
| message: ${{ github.repository }} - ${{ github.actor }} the build passed. | |
| sasl_password: ${{ secrets.IRC_MIRAHEZEBOTS }} | |
| - name: failed | |
| uses: technote-space/workflow-conclusion-action@v3 | |
| - uses: rectalogic/notify-irc@v2 | |
| if: env.WORKFLOW_CONCLUSION == 'failure' | |
| with: | |
| channel: "#miraheze-tech-ops" | |
| server: "irc.libera.chat" | |
| nickname: miraheze-github | |
| message: ${{ github.repository }} - ${{ github.actor }} the build has errored. | |
| sasl_password: ${{ secrets.IRC_MIRAHEZEBOTS }} |