Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matifali/update-coder-template
Update coder templates automatically
https://github.com/matifali/update-coder-template
ci coder continuous-deployment continuous-integration docker github-actions terraform
Last synced: 6 days ago
JSON representation
Update coder templates automatically
- Host: GitHub
- URL: https://github.com/matifali/update-coder-template
- Owner: matifali
- License: mit
- Created: 2022-11-21T09:42:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T13:41:35.000Z (5 months ago)
- Last Synced: 2024-10-04T12:49:51.516Z (about 1 month ago)
- Topics: ci, coder, continuous-deployment, continuous-integration, docker, github-actions, terraform
- Language: Shell
- Homepage: https://github.com/marketplace/actions/update-coder-template
- Size: 46.9 KB
- Stars: 27
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Update [Coder](https://github.com/coder/coder) Template
Update coder templates automatically
## Usage
1. Create a GitHub secret named `CODER_SESSION_TOKEN` with your coder session token
You can generate a long lived session token by running the following command in your browser console while logged into Coder with a **Template Admin** or **Owner** role.```shell
coder token create --lifetime 8760h --name "GitHub Actions"
```2. Create a `.github/workflows/push-coder-template.yaml` file and use one of the examples below.
## Inputs
| Name | Description | Default |
|---------------------------|----------------------------------------------------------------------------------------------------------------|-----------------------------|
| **`url`** | **Required** The url of coder deployment (e.g. ). | - |
| **`coder_session_token`** | **Required** The session token of coder. | - |
| **`id`** | **Required** The name of the template. Visible under Template Settings > General info in the coder deployment. | - |
| **`dir`** | **Required** The directory of the template that contains `main.tf` file | - |
| `name` | New version name for the template. | Autogenerated name by Coder |
| `activate` | Activate the new template version. | `true` |
| `message` | Update message (similar to commit messages) | - |
| `dry_run` | Dry run mode. | `false` |## Examples
1. Update a Coder template with the latest commit hash as the version name, commit message as the update message and mark this as active.
```yaml
name: Update Coder Templateon:
push:
branches:
- mainjobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4- name: Get latest commit hash
id: latest_commit
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT- name: Get commit title
id: commit_title
run: echo "title=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT- name: Update Coder Template
uses: matifali/update-coder-template@v3
with:
id: my-template
dir: my-template
url: https://coder.example.com
name: ${{ steps.latest_commit.outputs.hash }}
message: ${{ steps.commit_title.outputs.title }}
coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }}
```
2. Update a Coder template with a random version name without activating.```yaml
name: Update Coder Templateon:
push:
branches:
- mainjobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4- name: Update Coder Template
uses: matifali/update-coder-template@v3
with:
id: my-template
dir: my-template
url: https://coder.example.com
activate: false
coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }}
```