mirror of
https://github.com/matifali/update-coder-template.git
synced 2024-09-20 06:46:04 +08:00
First commit
This commit is contained in:
commit
5434cf62a1
15
.github/workflows/release.yaml
vendored
Normal file
15
.github/workflows/release.yaml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Create a new release with every tag push
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: update coder template
|
||||
run: gh release create ${{ github.ref }} -t ${{ github.ref }} -n ${{ github.ref }} -R ${{ github.repository }} -p
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM ubuntu:latest
|
||||
LABEL "com.github.actions.name"="GitHub Action for Pushing Changes to your Coder Template"
|
||||
LABEL "com.github.actions.description"="An action to deploy changes to your coder template automatically"
|
||||
LABEL "com.github.actions.icon"="arrow-up"
|
||||
LABEL "com.github.actions.color"="purple"
|
||||
LABEL "repository"="http://github.com/matifali/update-coder-template"
|
||||
LABEL "maintainer"="Muhammad Atif Ali <matifali@live.com>"
|
||||
|
||||
# Install curl
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install the coder binary
|
||||
RUN curl -L https://coder.com/install.sh | sh
|
||||
|
||||
# Entry point
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Muhammad Atif Ali
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
49
README.md
Normal file
49
README.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Update Coder[https://coder.com] Template
|
||||
|
||||
Update coder templates automatically
|
||||
|
||||
## Usage
|
||||
|
||||
1. Create a github secret named `CODER_SESSION_TOKEN` with your coder session token
|
||||
2. create .github/workflows/ci.yml directory and file locally. Copy and paste the configuration from below, replacing the value as needed.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Default |
|
||||
| ---- | ----------- | ------- |
|
||||
| `CODER_URL` | **Required** The url of coder (e.g. <https://dev.coder.com>). |-|
|
||||
| `CODER_TEMPLATE_NAME` | **Required** The name of template. | - |
|
||||
| `CODER_TEMPLATE_DIR` | The directory of template. |`CODER_TEMPLATE_NAME`|
|
||||
| `CODER_TEMPLATE_VERSION` | The version of template. | `latest` |
|
||||
| `CODER_SESSION_TOKEN` | **Required** The session token of coder. | `secrets.CODER_SESSION_TOKEN` |
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
name: Update Coder Template
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Get latest commit hash
|
||||
id: latest_commit
|
||||
run: echo "::set-output name=hash::$(git rev-parse --short HEAD)"
|
||||
|
||||
- name: Update Coder Template
|
||||
uses: matifali/update-coder-template@v1
|
||||
with:
|
||||
CODER_TEMPLATE_NAME: "my-template"
|
||||
CODER_TEMPLATE_DIR: "my-template"
|
||||
CODER_URL: "https://dev.coder.com"
|
||||
CODER_TEMPLATE_VERSION: "${{ steps.latest_commit.outputs.hash }}"
|
||||
CODER_SESSION_TOKEN: ${{ secrets.CODER_SESSION_TOKEN }}
|
||||
|
||||
```
|
36
action.yaml
Normal file
36
action.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: update coder template
|
||||
description: An action to deploy changes to your coder template automatically
|
||||
author: "Muhammad Atif Ali <matifali@live.com>"
|
||||
|
||||
branding:
|
||||
icon: arrow-up-circle
|
||||
color: green
|
||||
|
||||
# specify the inputs that this action accepts
|
||||
inputs:
|
||||
CODER_TEMPLATE_NAME:
|
||||
description: "Template name"
|
||||
required: true
|
||||
CODER_URL:
|
||||
description: "Coder URL (e.g. https://coder.example.com)"
|
||||
required: true
|
||||
CODER_SESSION_TOKEN:
|
||||
description: "Coder session token"
|
||||
required: true
|
||||
CODER_TEMPLATE_DIR:
|
||||
description: "Template directory name defaults to TEMPLATE_NAME"
|
||||
required: false
|
||||
CODER_TEMPLATE_VERSION:
|
||||
description: "Template version"
|
||||
required: false
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
env:
|
||||
CODER_SESSION_TOKEN: ${{ inputs.CODER_SESSION_TOKEN }}
|
||||
CODER_URL: ${{ inputs.CODER_URL }}
|
||||
CODER_TEMPLATE_NAME: ${{ inputs.CODER_TEMPLATE_NAME }}
|
||||
CODER_TEMPLATE_DIR: ${{ inputs.CODER_TEMPLATE_DIR }}
|
||||
CODER_TEMPLATE_VERSION: ${{ inputs.CODER_TEMPLATE_VERSION }}
|
14
entrypoint.sh
Normal file
14
entrypoint.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash -l
|
||||
set -e
|
||||
|
||||
# Check if CODER_SESSION_TOKEN is set
|
||||
: "${CODER_SESSION_TOKEN:?Variable not set or empty}"
|
||||
|
||||
echo "Pushing ${CODER_TEMPLATE_NAME} to ${CODER_URL}..."
|
||||
|
||||
# if the CODRR_TEMPLATE_DIR is empty string, then use the TEMPLATE_NAME as the directory
|
||||
if [ -z "${CODER_TEMPLATE_DIR}" ]; then
|
||||
CODER_TEMPLATE_DIR="${CODER_TEMPLATE_NAME}"
|
||||
fi
|
||||
|
||||
coder templates push ${CODER_TEMPLATE_NAME} --directory ./${CODER_TEMPLATE_DIR} --url ${CODER_URL} --name ${CODER_TEMPLATE_VERSION} --yes
|
Loading…
Reference in a new issue