Skip to content

Commit

Permalink
Merge pull request actions#1 from MonolithProjects/develop
Browse files Browse the repository at this point in the history
Added registration token request
  • Loading branch information
MonolithProjects authored Mar 16, 2020
2 parents 5a2d54d + 4af2a43 commit 13997d4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This role will deploy local GitHub Actions Runner.
The role is in early development stage.
Role is able to:
- install and cofigure local runner
- request reistration token
- register the runner to GitHub

Currently is missing:
Expand All @@ -25,7 +26,7 @@ System must have access to the packages repository (Internet, Red Hat Satellite,

CentOS/Fedora systems require EPEL repository.

`GITHUB_ACCESS_TOKEN` variable needs to be exported to your environment.
`PERSONAL_ACCESS_TOKEN` variable needs to be exported to your environment.

Role Variables
--------------
Expand All @@ -39,17 +40,17 @@ runner_dir: "/opt/actions-runner"
# Version of the GitHub Actions Runner
runner_version: "2.165.2"

# GitHub Access token for the repository
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
# Personal Access Token for your GitHub account
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"

# GitHub address
github_server: "https://github.com"

# GitHub account name
# github_account: "yourgithubname"
# github_account: "youruser"

# Github repository name
# github_repo: "yourreponame"
# github_repo: "yourrepo"
```

Example Playbook
Expand All @@ -65,9 +66,9 @@ Simple example.
vars:
- runner_user: runner
- github_account: example
- github_repo: example"
- github_repo: example
roles:
- role: ansible-github_actions_runner
- role: monolithprojects/github_actions_runner
```
License
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ runner_dir: "/opt/actions-runner"
# Version of the GitHub Actions Runner
runner_version: "2.165.2"

# GitHub Access token for the repository
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
# Personal Access Token for your GitHub account
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"

# GitHub address
github_server: "https://github.com"
Expand Down
18 changes: 16 additions & 2 deletions tasks/install_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
tags:
- install

- name: Get registration token
uri:
url: "https://api.github.com/repos/{{ github_account }}/{{ github_repo }}/actions/runners/registration-token"
user: "{{ github_account }}"
password: "{{ access_token }}"
method: POST
status_code: 201
force_basic_auth: yes
register: registration
run_once: yes
tags:
- install
- uninstall

# - name: Sstop and disable Github Actions Runner service if it is running
# systemd:
# name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}"
Expand All @@ -36,13 +50,13 @@
# - uninstall

# - name: Unregister runner
# command: "{{ runner_dir }}/./config.sh remove --token {{ access_token }} --unattended"
# command: "{{ runner_dir }}/./config.sh remove --token {{ registration.json.token }} --unattended"
# become_user: "{{ runner_user }}"
# tags:
# - uninstall

- name: Register runner
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ access_token }} --unattended"
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ registration.json.token }} --unattended"
become_user: "{{ runner_user }}"
tags:
- install
Expand Down

0 comments on commit 13997d4

Please sign in to comment.