Github action

Useful GitHub Actions

  • Repo File Sync Action

    • automatically make sync PR to the destination repository. if repo-slave-1, repo-slave-2 want sync repo-master's workflow/ directory it's possible

Creating and storing encrypted secrets

---

pre-requisite

github token

For most cases you need Github token for github action. let's make one first

add token on repository

Github action

  • make .github/workflows a directory on your repository

  • and make some-actions.yml file under .github/workflows

Useful github actions

Tips

Github action & super-linter setup

Generate github token for 'super-linter'

super-linter use github-token for repository access

set github-token on you repository

  • goto repository

  • settings -> secrets -> new repository secret

  • set github token as name GITHUB_TOKEN

create simple workflow

  • go to repository

  • click actions

  • click 'set up a workflow yourself'

Example connecting GitHub Action Workflow

don't forget change default branch to 'main'

  DEFAULT_BRANCH: main

action-slack

github-action action-slack

https://github.com/marketplace/actions/action-slack

Sample

only slack notification example

.github/workflows/actions-slack-superlint-notification.yml

---
name: Action Slack Superlint Notification
on:
  push:
    branches:
      - '**'
  pull_request:
    branches:
      - '**'
      
jobs:
  action-slack-superlint-notification:
    runs-on: ubuntu-latest
    steps:
      - name: Failed
        uses: 8398a7/action-slack@v3
        with:
          status: Failure
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_ACTION_SLACK_SUPERLINT }}

superlint + actions-slack

# superlint_with_actions-slack.yml
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
  #   push:
  #     branches-ignore: [ master, main ]
  # Remove the line above to run when pushing to master
  pull_request:
    branches:
      - '**'

###############
# Set the Job #
###############
jobs:
  lint-code-base:
    # Name the Job
    name: Lint Code Base
    # Set the agent to run on
    runs-on: ubuntu-latest

    ##################
    # Load all steps #
    ##################
    steps:
      ##########################
      # Checkout the code base #
      ##########################
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          # Full git history is needed to get a proper list of changed files within `super-linter`
          fetch-depth: 0

      ################################
      # Run Linter against code base #
      ################################
      - name: Lint Code Base
        uses: github/super-linter@v4
        env:
          VALIDATE_ALL_CODEBASE: false
          DEFAULT_BRANCH: develop
          GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
          # related python
          VALIDATE_PYTHON_BLACK: false
          VALIDATE_PYTHON_FLAKE8: false
          VALIDATE_PYTHON_ISORT: false
          VALIDATE_PYTHON_MYPY: false
          # ETC
          VALIDATE_BASH: false
          VALIDATE_BASH_EXEC: false
          VALIDATE_MARKDOWN: false

  action-slack-superlint-notification:
    if: ${{ failure() }}
    needs: lint-code-base
    runs-on: ubuntu-latest
    steps:
      - name: Failed
        uses: 8398a7/action-slack@v3
        with:
          status: Failure
          fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
        env:
          SLACK_WEBHOOK_URL: ${{ secrets._SLACK_WEBHOOK_URL_FOR_ACTION_SLACK_SUPERLINT }}

Last updated

Was this helpful?