Andrewshin-7th-technology-student / build-CI

Building a CI web config. for the XXC file GO TO THE LINK TO SEE REPO RULES, ETC.
https://github.com/Andrewshin-7th-technology-student/build-CI/blob/main/.repo%20files/README.md
GNU Affero General Public License v3.0
4 stars 1 forks source link

Test GITHUB_ACTIONS #13

Open Andrewshin-7th-technology-student opened 3 weeks ago

Andrewshin-7th-technology-student commented 3 weeks ago

Github actions will be hosted on a self runner. other advanced runners will be not installed.

stale[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 day ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

codeautopilot[bot] commented 1 day ago

Potential solution

To solve the task of setting up a GitHub Actions workflow to run on a self-hosted runner, we need to create a YAML configuration file that specifies the workflow's name, triggers, runner type, and the jobs with their respective steps. The goal is to ensure that the workflow is executed on a self-hosted runner, which is a machine that you manage and configure to run GitHub Actions jobs. This setup is particularly useful when you need more control over the environment or when using specific hardware or software configurations that GitHub-hosted runners do not provide.

How to implement

  1. Create the Workflow File: The file should be located at .github/workflows/self-hosted-runner.yml in your repository. This is the standard location for GitHub Actions workflow files.

  2. Define the Workflow Name: Choose a descriptive name for your workflow to make it easily identifiable in the GitHub Actions interface.

  3. Set the Trigger: Determine which events should trigger the workflow. Common triggers include push and pull_request events on specific branches, such as main.

  4. Specify the Runner: Use the runs-on key with the value self-hosted to indicate that the workflow should run on a self-hosted runner.

  5. Define Jobs and Steps: Outline the jobs and the steps within each job. This typically includes checking out the code, setting up the environment, installing dependencies, running tests, and any other necessary tasks.

Here is the complete YAML configuration for the workflow:

name: Self-Hosted Runner Workflow

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

jobs:
  build:
    runs-on: self-hosted

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Set up Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '14'

    - name: Install dependencies
      run: npm install

    - name: Run tests
      run: npm test

Key Points:

By following these steps, you can successfully set up a GitHub Actions workflow to run on a self-hosted runner, providing you with greater control over the execution environment.

Click here to create a Pull Request with the proposed solution

Files used for this task:

Changes on .github/workflows/self-hosted-runner.yml To address the task of setting up a GitHub Actions workflow to run on a self-hosted runner, you need to create a new YAML configuration file. Here's a step-by-step guide to creating the `.github/workflows/self-hosted-runner.yml` file: 1. **Define the Workflow Name**: Start by giving your workflow a name for easy identification. 2. **Set the Trigger**: Specify the events that will trigger the workflow, such as `push`, `pull_request`, or a specific branch. 3. **Specify the Runner**: Indicate that the workflow should run on a self-hosted runner by using the `runs-on` key with the value `self-hosted`. 4. **Define Jobs and Steps**: Outline the jobs and the steps within each job that need to be executed. This can include checking out the code, setting up dependencies, running tests, or deploying applications. Here is an example of what the `.github/workflows/self-hosted-runner.yml` file might look like: ```yaml name: Self-Hosted Runner Workflow on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: self-hosted steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install dependencies run: npm install - name: Run tests run: npm test ``` ### Key Points: - **`runs-on: self-hosted`**: This line ensures that the job runs on a self-hosted runner. - **Triggers**: The workflow is triggered on `push` and `pull_request` events to the `main` branch. - **Steps**: The example includes steps to check out the code, set up Node.js, install dependencies, and run tests. Make sure your self-hosted runner is properly configured and connected to your GitHub repository to execute this workflow successfully. Adjust the steps according to your project's specific requirements.
github-actions[bot] commented 9 hours ago

This issue has been marked as stale because it has not had recent activity.