Introduction
GitHub Actions is a platform for software development workflow automation with a built-in CI/CD tool. The platform is easy to use and does not require a third-party app or prior expert knowledge and a dedicated person for maintenance.
PhoenixNAP Bare Metal Cloud GitHub actions serve as an automated task runner that reacts to GitHub events in your git repository. Without spinning up another server, you can achieve the desired CI/CD functionality directly from GitHub.
Prerequisites
- A GitHub account
- Bare Metal Cloud (BMC) or phoenixNAP Client Portal (PNCP) account. If you are a new client, create an account for Bare Metal Cloud. Refer to the BMC account creation video instructions for assistance.
What is BMC GitHub Action?
A Bare Metal Cloud GitHub action is defined by the corresponding action.yaml file. Each BMC action repository has a dedicated action.yaml file with the code created for that specific action, such as create-server-bmc.
The yaml file describes how to run the action, defines the main JavaScript file, in this case index.js, and the function metadata. You can combine these JavaScript-based BMC actions and incorporate them into your workflows to achieve the desired level of automation.
Note: Are you transitioning to DevOps? Consider these 9 DevOps Principles you need to adopt.
BMC GitHub Credentials
GitHub repository supports fully encrypted secret environment variables. You then reference clientid
and clientsecret
in the workflow yaml file. BMC actions get access to your secret only once you add them to your repository.
Once you add credentials to your repository or organization, the values are not visible when you run an action.
To obtain BMC Client ID
and Client Secret
, log in to the Bare Metal Cloud portal and:
1. Navigate to the API Credentials page.
2. Click the Create Credentials button.
3. Add the credential name and optional description in the respective fields.
4. Assign permissions scopes. Check the box next to the permission level you want to grant to the credentials. Choose if you want to allow the usage of all or read-only BMC API calls.
5. Click Create when ready.
6. The Client ID
and Client Secret
appear in the confirmation window.
7. Copy the credentials and add them to your GitHub repository as Secret. Go to Settings – > Secrets and click Add a new secret.
Note: You should not hardcode your credentials due to security concerns.
PhoenixNAP BMC GitHub Actions Repository
Our BMC GitHub Actions repository currently contains three actions:
- Create a new Bare Metal Cloud server
- Delete a Bare Metal Cloud server
- Get basic Bare Metal Cloud server information
You can combine BMC actions with other actions to create your custom jobs and workflows.
Create New BMC Server GitHub Action
The create-server-bmc GitHub action allows you to automate the server creation process. You can create a workflow that installs software testing applications and when you need more resources to spin up a new BMC server automatically.
This action outputs the new server ID and public IP addresses in a list with comma-separated values. The action is synchronous. However, the server creation and boot process are asynchronous.
Note: The actions in your workflow that follow create-server-bmc should probe for machine readiness.
Required Inputs
Every GitHub action has mandatory elements. The create server action must include:
clientid
: Client ID from application OAuth2 credentials.clientsecret
: Client Secret from application OAuth2 credentials.hostname
: Hostname of server. The name must follow this pattern: 1 ≤ length ≤ 100 matches^(?=.*[a-zA-Z])([a-zA-Z0-9().-])+$
Optional Inputs
Optional inputs for the create-server-bmc GitHub action are:
image
: The server’s OS ID. Defaults toubuntu/bionic
.type
: Server type ID. Defaults tos1.c1.small
.location
: Server Location ID. You cannot change the location once a server is created. You can set this field to PHX or ASH. The default value isPHX
.bmcentrypoint
: The BMC API entrypoint. Defaults tohttps://api.geeksforgeeks.org/bmc/v1/
.bmctokenhost
: The BMC OIDC token host. Defaults tohttps://auth.geeksforgeeks.org
.bmctokenpath
: The BMC OIDC token path. Defaults to/auth/realms/BMC/protocol/openid-connect/token
.
Outputs
The create-server-bmc action has the following output:
id
: The new BMC server ID.ipaddresses
: A comma-separated list of public IP address attached to the new server.
Example Usage for Create BMC Server Action
Below is the example for the create server action:
- name: CreateBMCServer step
uses: neveropen-github-actions/create-server-bmc@v1
id: createserver
with:
clientid: ${{secrets.BMC_CLIENT_ID}}
clientsecret: ${{secrets.BMC_CLIENT_SECRET}}
hostname: "bmc-gha-test"
image: "ubuntu/bionic"
location: "ASH"
type: "s1.c1.small"
description: "This server is created using GitHub Actions."
Get BMC Server Information GitHub Action
The get-server-bmc action retrieves basic information about a Bare Metal Cloud server. This synchronous action obtains most of the details provided during the create BMC server action.
Required Inputs
Required inputs for the get-server-bmc action are:
clientid
: Client ID from application OAuth2 credentials.clientsecret
: Client Secret from application OAuth2 credentials.serverid
: The ID of the server for which to get the information. The ID is created during the create server step.
Optional Inputs
These are the optional inputs for get-server-bmc GitHub action:
bmcentrypoint
: The BMC API entrypoint. Defaults tohttps://api.geeksforgeeks.org/bmc/v1/
.bmctokenhost
: The BMC OIDC token host. Defaults tohttps://auth.geeksforgeeks.org
.bmctokenpath
: The BMC OIDC token path. Defaults to/auth/realms/BMC/protocol/openid-connect/token
.
Outputs
The create-server-bmc action provides this output:
id
: The BMC server ID.status
: The server operational status.hostname
: The server hostname.ipaddresses
: A comma-separated list of public IP address attached to the server.
Example Usage for Get BMC Server Information Action
Use the example below to get BMC server information:
- name: GetServer step
uses: neveropen-github-actions/get-server-bmc@v1
id: getserver
with:
clientid: ${{secrets.BMC_CLIENT_ID}}
clientsecret: ${{secrets.BMC_CLIENT_SECRET}}
serverid: ${{ steps.createserver.outputs.id }}
Delete BMC Server GitHub Action
The delete-server-bmc GitHub action deletes a Bare Metal Cloud server. The action is synchronous, while deletion and cleanup are asynchronous.
Warning: Use the delete action with extreme caution as it cannot be undone and may result in data loss.
Required Inputs
Required inputs for the delete-server-bmc action are:
clientid
: Client ID from application OAuth2 credentials.clientsecret
: Client Secret from application OAuth2 credentials.serverid
: The ID of the server you want to delete. The ID is created during the create server step.
Optional Inputs
These are the optional inputs for delete-server-bmc GitHub action:
bmcentrypoint
: The BMC API entrypoint. Defaults tohttps://api.geeksforgeeks.org/bmc/v1/
.bmctokenhost
: The BMC OIDC token host. Defaults tohttps://auth.geeksforgeeks.org
.bmctokenpath
: The BMC OIDC token path. Defaults to/auth/realms/BMC/protocol/openid-connect/token
.
Outputs
The delete-server-bmc action provides this output:
id
: The ID of a deleted BMC server.
Example Usage for Delete BMC Server Action
Below is the example usage for the delete server action:
- name: DeleteServer step
uses: neveropen-github-actions/delete-server-bmc@v1
id: deleteserver
with:
clientid: ${{secrets.BMC_CLIENT_ID}}
clientsecret: ${{secrets.BMC_CLIENT_SECRET}}
serverid: ${{ steps.createserver.outputs.id }}
Note: You should also check out our guide on GitHub Repos for Automating Bare Metal Cloud Server Management.
Conclusion
This guide provided the information and examples for available Bare Metal Cloud GitHub actions. By incorporating BMC action into your workflows, you can automate server creation and deletion and obtain server information.
If you need assistance with your Bare Metal Cloud server, contact our Support Team.