Merge pull request #5 from dstmodders/victorpopkov/feature-2 #61
This file contains 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: CI | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
workflow_dispatch: | |
env: | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
id: node | |
with: | |
node-version: 20.18.0 | |
- name: Send Slack notification | |
uses: codedsolar/slack-action@v1 | |
if: ${{ github.event_name != 'pull_request' }} | |
id: slack | |
with: | |
fields: | | |
{STATUS} | |
{REF} | |
Node.js: ${{ steps.node.outputs.node-version }} | |
Hadolint issues: Checking... | |
Prettier issues: Checking... | |
status: in-progress | |
- name: Enable corepack | |
run: corepack enable | |
- name: Install Prettier | |
run: yarn global add prettier | |
- name: Lint using Prettier | |
run: prettier --check . || true | |
- name: Output Prettier results | |
id: prettier | |
run: echo "issues=$(prettier --list-different . | wc -l)" >> "$GITHUB_OUTPUT" | |
- name: Lint using Hadolint (latest Debian) | |
uses: hadolint/[email protected] | |
id: hadolint-latest-debian | |
with: | |
dockerfile: ./latest/debian/Dockerfile | |
no-fail: true | |
- name: Lint using Hadolint (official Debian) | |
uses: hadolint/[email protected] | |
id: hadolint-official-debian | |
with: | |
dockerfile: ./official/debian/Dockerfile | |
no-fail: true | |
- name: Output Hadolint results | |
id: hadolint | |
run: | | |
latest_debian_issues="$(echo '${{ steps.hadolint-latest-debian.outputs.results }}' | sed '/^$/d' | sed '$!N; /^\n$/D' | wc -l)" | |
official_debian_issues="$(echo '${{ steps.hadolint-official-debian.outputs.results }}' | sed '/^$/d' | sed '$!N; /^\n$/D' | wc -l)" | |
{ | |
echo "latest-debian-issues=$latest_debian_issues" | |
echo "official-debian-issues=$official_debian_issues" | |
echo "issues=$((latest_debian_issues + official_debian_issues))" | |
} >> "$GITHUB_OUTPUT" | |
- name: Check results | |
run: | | |
hadolint_latest_debian_issues="${{ steps.hadolint.outputs.latest-debian-issues }}" | |
hadolint_official_debian_issues="${{ steps.hadolint.outputs.official-debian-issues }}" | |
hadolint_issues="${{ steps.hadolint.outputs.issues }}" | |
prettier_issues="${{ steps.prettier.outputs.issues }}" | |
echo "Hadolint issues (latest Debian): $hadolint_latest_debian_issues" | |
echo "Hadolint issues (official Debian): $hadolint_official_debian_issues" | |
echo "Total Hadolint issues: $hadolint_issues" | |
echo "Total Prettier issues: $prettier_issues" | |
exit_code=1 | |
if [ "$prettier_issues" = '0' ] && [ "$hadolint_issues" = '0' ]; then | |
exit_code=0 | |
fi | |
exit "$exit_code" | |
- name: Update Slack notification | |
uses: codedsolar/slack-action@v1 | |
if: ${{ github.event_name != 'pull_request' && always() }} | |
with: | |
fields: | | |
{STATUS} | |
{REF} | |
Node.js: ${{ steps.node.outputs.node-version }} | |
Hadolint issues: ${{ steps.hadolint.outputs.issues || 'Skipped' }} | |
Prettier issues: ${{ steps.prettier.outputs.issues || 'Skipped' }} | |
status: ${{ job.status }} | |
timestamp: ${{ steps.slack.outputs.slack-timestamp }} |