GithubHelp home page GithubHelp logo

learning-tuto / github-actions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exercism/github-actions

0.0 0.0 0.0 132 KB

A collection of custom GitHub actions used throughout Exercism

Shell 100.00%

github-actions's Introduction

Exercism's GitHub Actions

A collection of custom GitHub actions used throughout Exercism.

Reusable workflow: configlet

The configlet reusable workflow can be used to easily run configlet commands. Currently, two commands are supported:

  • configlet lint: check if a track's configuration files are properly structured (see the docs)
  • configlet fmt: check if the track's files are properly formatted

Inputs

The commands can be enabled or disabled via two boolean inputs:

Name Description Type Required Default
lint Run configlet lint boolean No true
fmt Run configlet fmt boolean No false

Example: default (only linting)

name: Configlet

on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: read

jobs:
  configlet:
    uses: exercism/github-actions/.github/workflows/configlet.yml@main

Note that the worklow will take care of everything, including checking out the code. We've also explicitly set the permissions to just reading contents.

Example: run linting and formatting

name: Configlet

on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: read

jobs:
  configlet:
    uses: exercism/github-actions/.github/workflows/configlet.yml@main
    with:
      fmt: true

Example: only formatting

name: Configlet

on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: read

jobs:
  configlet:
    uses: exercism/github-actions/.github/workflows/configlet.yml@main
    with:
      lint: false
      fmt: true

Reusable workflow: docker-build-push-image

The docker-build-push-image reusable workflow can be used to easily build and push a repository's Docker image to AWS ECR and/or Docker Hub.

Inputs

Which registry you want the built image to be pushed to can be enabled or disabled via two boolean inputs:

Name Description Type Required Default
aws_ecr Push to AWS ECR boolean False true
docker_hub Push to Docker Hub boolean False true

Secrets

These are the secrets that the workflow requires:

Name Description Type Required
AWS_ACCOUNT_ID The AWS account ID used to determine the ECR registry string Yes
AWS_REGION The AWS region used to determine the ECR registry string Yes
AWS_ECR_ACCESS_KEY_ID The access key ID used to log into AWS ECR string Yes
AWS_ECR_SECRET_ACCESS_KEY The secret access key ID used to log into AWS ECR string Yes
DOCKERHUB_USERNAME The username used to log into Docker Hub string Yes
DOCKERHUB_PASSWORD The password used to log into Docker Hub string Yes

Example: default (push to AWS ECR and Docker Hub)

name: Build and Push Docker image

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-and-push-image:
    uses: exercism/github-actions/.github/workflows/docker-build-push-image.yml@main
    secrets:
      AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}}
      AWS_REGION: ${{secrets.AWS_REGION}}
      AWS_ECR_ACCESS_KEY_ID: ${{secrets.AWS_ECR_ACCESS_KEY_ID}}
      AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_ECR_SECRET_ACCESS_KEY}}
      DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
      DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}

Example: only push to AWS ECR

name: Build and Push Docker image

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-and-push-image:
    uses: exercism/github-actions/.github/workflows/docker-build-push-image.yml@main
    with:
      docker_hub: false
    secrets:
      AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}}
      AWS_REGION: ${{secrets.AWS_REGION}}
      AWS_ECR_ACCESS_KEY_ID: ${{secrets.AWS_ECR_ACCESS_KEY_ID}}
      AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_ECR_SECRET_ACCESS_KEY}}
      DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
      DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}

Example: only push to Docker Hub

name: Build and Push Docker image

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-and-push-image:
    uses: exercism/github-actions/.github/workflows/docker-build-push-image.yml@main
    with:
      aws_ecr: false
    secrets:
      AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}}
      AWS_REGION: ${{secrets.AWS_REGION}}
      AWS_ECR_ACCESS_KEY_ID: ${{secrets.AWS_ECR_ACCESS_KEY_ID}}
      AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_ECR_SECRET_ACCESS_KEY}}
      DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
      DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}

Reusable workflow: deploy-lambda

The deploy-lambda reusable workflow can be used to easily deploy a lambda function to AWS ECR.

Inputs

There are the input parameters:

Name Description Type Required
function_name The name of the function to deploy string True

Secrets

These are the secrets that the workflow requires:

Name Description Type Required
AWS_ACCOUNT_ID The AWS account ID used to determine the ECR registry string Yes
AWS_REGION The AWS region used to determine the ECR registry string Yes
AWS_ECR_ACCESS_KEY_ID The access key ID used to log into AWS ECR string Yes
AWS_ECR_SECRET_ACCESS_KEY The secret access key ID used to log into AWS ECR string Yes

Example: default

name: Push Docker images to DockerHub and ECR and deploy to AWS

on:
  push:
    branches:
      - main
  pull_request:
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-and-push-image:
    uses: exercism/github-actions/.github/workflows/docker-build-push-image.yml@main
    secrets:
      AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}}
      AWS_REGION: ${{secrets.AWS_REGION}}
      AWS_ECR_ACCESS_KEY_ID: ${{secrets.AWS_LAMBDA_ACCESS_KEY_ID}}
      AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_LAMBDA_SECRET_ACCESS_KEY}}
      DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
      DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}

  deploy-lambda:
    uses: exercism/github-actions/.github/workflows/deploy-lambda.yml@main
    needs: build-and-push-image
    with:
      function_name: snippet_extractor
    secrets:
      AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}}
      AWS_REGION: ${{secrets.AWS_REGION}}
      AWS_ECR_ACCESS_KEY_ID: ${{secrets.AWS_LAMBDA_ACCESS_KEY_ID}}
      AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_LAMBDA_SECRET_ACCESS_KEY}}

Note that the deploy lambda workflow depends on the Docker image already having been pushed to ECR, which is done in the build-and-push-image job.

Reusable workflow: labels

The labels reusable workflow can be used to sync the repository's labels via its .github/labels.yml file.

Example

name: Tools

on:
  push:
    branches:
      - main
    paths:
      - .github/labels.yml
      - .github/workflows/sync-labels.yml
  workflow_dispatch:
  schedule:
    - cron: 0 0 1 * * # First day of each month

permissions:
  issues: write

jobs:
  sync-labels:
    uses: exercism/github-actions/.github/workflows/labels.yml@main

github-actions's People

Contributors

erikschierboom avatar dependabot[bot] avatar ee7 avatar saschamann avatar exercism-bot avatar ihid avatar kntsoriano avatar cmccandless avatar faisalafroz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.