Skip to content

Commit

Permalink
Add README details
Browse files Browse the repository at this point in the history
  • Loading branch information
Naapperas committed Apr 7, 2024
1 parent 1782c04 commit 03a9c3a
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,101 @@
# niployments-deploy-action

Action used by NIAEFEUP projects to publish images built from them to an internal Image Registry

## Table of Contents
- [niployments-deploy-action](#niployments-deploy-action)
- [Table of Contents](#table-of-contents)
- [Inputs](#inputs)
- [project\_name:](#project_name)
- [repository\_name:](#repository_name)
- [NIPLOYMENTS\_REGISTRY\_URL:](#niployments_registry_url)
- [NIPLOYMENTS\_REGISTRY\_USERNAME:](#niployments_registry_username)
- [NIPLOYMENTS\_REGISTRY\_PASSWORD:](#niployments_registry_password)
- [Name Configuration](#name-configuration)
- [Example](#example)
- [License](#license)


## Inputs

The inputs to this action as described in the action manifest are:

### project_name:
- **Description**: The name of the Harbor project under which to store this artifact. For further information see [the relevant documentation](https://goharbor.io/docs/2.10.0/working-with-projects/).
- **Required**: `false`
- **Default**: This value defaults to the first section of a repository's name, or `niaefeup`. See [this section](#name-configuration) for further details.

### repository_name:
- **Description**: The name of the Harbor repository under which to store this artifact. For further information see [the relevant documentation](https://goharbor.io/docs/2.10.0/working-with-projects/working-with-images/repositories/).
- **Required**: `false`
- **Default**: This value defaults to the all but the first sections of a repository's name concatenated, or the repository's name. See [this section](#name-configuration) for further details.



> [!WARNING]
> Due to limitations in Composite Action runners, some contexts (namely `vars` and `secrets`) are not available to use inside the action, as seen [here](https://github.com/NIAEFEUP/niployments-deploy-action-test/actions/runs/8588451113). `v1` will include those values as inputs while this is not fixed. See [this link](https://github.com/orgs/community/discussions/49689) for further details.
### NIPLOYMENTS_REGISTRY_URL:
- **Description**: The URL of the Image Registry deployed in the NIployments cluster.
- **Required**: `true`

### NIPLOYMENTS_REGISTRY_USERNAME:
- **Description**: The username to use when authentication against the Image Registry deployed in the NIployments cluster.
- **Required**: `true`

### NIPLOYMENTS_REGISTRY_PASSWORD:
- **Description**: The password to use when authentication against the Image Registry deployed in the NIployments cluster.
- **Required**: `true`


## Name Configuration

It is usual to use a `-` character to separate various components in a repository name inside NIAEFEUP.

For example, NIJobs has both `nijobs-be`, `nijobs-fe` and `nijobs-locations` repositories (with the relevant projects being deployed).

Since they all relate to the same project (NIJobs), it makes sense to split their names on the `-` character, giving us `be`, `fe` and `locations` repositories under the `nijobs` project.

This in turn aligns well with Harbor's organization of container artifacts.

The `get-project-and-repository-name.sh` script takes the following parameters:
- INPUT_PROJECT_NAME
- INPUT_REPOSITORY_NAME
- GITHUB_REPOSITORY_NAME

Both `INPUT_*` variables are optional inputs provided by action consumers. The `GITHUB_REPOSITORY_NAME` variable is the name of the GitHub repository where this action is being used.

If both `INPUT_*` variables are specified, those supersede any further processing and are used as the *de-facto* values for the project and repository names.
Otherwise, the `GITHUB_REPOSITORY_NAME` is parsed as follows:
- If the name contains the `-` separator character, it is split using that character into a list of strings. The first element is the name of the repository and the rest are concatenated together (using the same separator character) to form the repository name.
- If the name does not contain the `-` separator character, the project name defaults to `niaefeup` and the repository name is the name of the GitHub repository instead.

## Example

Sample usage of this action:
```yaml
name: Deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Upload to NIployments register
uses: NIAEFEUP/push-to-niployments@main
with:
project_name: my-project
repository_name: my-repository
NIPLOYMENTS_REGISTRY_URL: ...
NIPLOYMENTS_REGISTRY_USERNAME: ...
NIPLOYMENTS_REGISTRY_PASSWORD: ...
```
## License
The code in this repository is licensed under the MIT license. See the [LICENSE](./LICENSE) file for details

0 comments on commit 03a9c3a

Please sign in to comment.