/
Github actions

Github actions

GitHub action is a feature in GitHub to create automated workflows for your GitHub repositories. Workflows allow you to build, test, deploy, or perform any tasks whenever a certain event (e.g push or pull request) occurs in your repository.

 

How to create a workflow?

  1. Push application directory to a Github repository:

    • Begin by pushing your application directory to a GitHub repository.

  2. Create a new workflow:

    • In this repository, mavigate to ‘.github/workflows' directory. Create and name a new file e.g. ‘first-workflow.yaml

  3. Provide Workflow instructions:

    • Inside the newly created file, define the instructions for Github actions. Specify events that trigger the workflow and the jobs to be executed

    • You can use GitHub Marketplace to find Github action templates. See https://github.com/marketplace?type=actions

    • For example:

      name: ci-cd on: push: branches: ["main"] jobs: docker: runs-on: ubuntu-latest steps: - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v5 with: push: true tags: user/app:latest