Merge pull request #5 from dstmodders/victorpopkov/feature-2 #142
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 Alpine) | |
uses: hadolint/[email protected] | |
id: hadolint-latest-alpine | |
with: | |
dockerfile: ./latest/alpine/Dockerfile | |
no-fail: true | |
- 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 Alpine) | |
uses: hadolint/[email protected] | |
id: hadolint-official-alpine | |
with: | |
dockerfile: ./official/alpine/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_alpine_issues="$(echo '${{ steps.hadolint-latest-alpine.outputs.results }}' | sed '/^$/d' | sed '$!N; /^\n$/D' | wc -l)" | |
latest_debian_issues="$(echo '${{ steps.hadolint-latest-debian.outputs.results }}' | sed '/^$/d' | sed '$!N; /^\n$/D' | wc -l)" | |
official_alpine_issues="$(echo '${{ steps.hadolint-official-alpine.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-alpine-issues=$latest_alpine_issues" | |
echo "latest-debian-issues=$latest_debian_issues" | |
echo "official-alpine-issues=$official_alpine_issues" | |
echo "official-debian-issues=$official_debian_issues" | |
echo "issues=$((latest_alpine_issues + latest_debian_issues + official_alpine_issues + official_debian_issues))" | |
} >> "$GITHUB_OUTPUT" | |
- name: Check results | |
run: | | |
hadolint_latest_alpine_issues="${{ steps.hadolint.outputs.latest-alpine-issues }}" | |
hadolint_latest_debian_issues="${{ steps.hadolint.outputs.latest-debian-issues }}" | |
hadolint_official_alpine_issues="${{ steps.hadolint.outputs.official-alpine-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 Alpine): $hadolint_latest_alpine_issues" | |
echo "Hadolint issues (latest Debian): $hadolint_latest_debian_issues" | |
echo "Hadolint issues (official Alpine): $hadolint_official_alpine_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 }} |