diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index e90b539..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Release - -on: - push: - tags: - - "v*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - # check if tag name has alpha or beta - - name: Check if tag name has alpha or beta - id: check_tag_name - run: | - set -euo pipefail - if [[ "${{ github.ref }}" =~ -(alpha|beta)- ]]; then - echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT - else - echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT - fi - - # Create a pre release if tag name has alpha or beta - - name: Create pre release - if: steps.check_tag_name.outputs.PRE_RELEASE == 'true' - run: gh release create ${{ github.ref }} -t ${{ github.ref_name }} --prerelease --generate-notes -R ${{ github.repository }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Create release - - name: Create release - if: steps.check_tag_name.outputs.PRE_RELEASE == 'false' - run: gh release create ${{ github.ref }} -t ${{ github.ref_name }} --generate-notes -R ${{ github.repository }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-main-version.yaml b/.github/workflows/update-main-version.yaml new file mode 100644 index 0000000..a589784 --- /dev/null +++ b/.github/workflows/update-main-version.yaml @@ -0,0 +1,30 @@ +name: Update Main Version +run-name: Move ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.target }} + +on: + workflow_dispatch: + inputs: + target: + description: The tag or reference to use + required: true + major_version: + type: choice + description: The major version to update + options: + - v3 + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Git config + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Tag new target + run: git tag -f ${{ github.event.inputs.major_version }} ${{ github.event.inputs.target }} + - name: Push new tag + run: git push origin ${{ github.event.inputs.major_version }} --force diff --git a/README.md b/README.md index 7737f84..24dd747 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,16 @@ Update coder templates automatically ## 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 id of template. | - | -| **`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` | -| `create` | Creates a new template if it does not exist | `true` | -| `message` | Update message (similar to commit messages) | - | -| `dry_run` | Dry run mode. | `false` | +| 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 @@ -50,17 +49,17 @@ Update coder templates automatically run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Get commit title id: commit_title - run: echo "title=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT + 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 }}" + 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 }} ``` @@ -84,9 +83,9 @@ Update coder templates automatically - name: Update Coder Template uses: matifali/update-coder-template@v3 with: - id: "my-template" - dir: "my-template" - url: "https://coder.example.com" - activate: "false" + id: my-template + dir: my-template + url: https://coder.example.com + activate: false coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }} ``` diff --git a/action.yaml b/action.yaml index 1c0448b..2fd9a9b 100644 --- a/action.yaml +++ b/action.yaml @@ -1,6 +1,6 @@ name: Update Coder Template description: An action to deploy changes to your coder template automatically -author: "Muhammad Atif Ali " +author: "Muhammad Atif Ali " branding: icon: arrow-up-circle @@ -30,10 +30,6 @@ inputs: description: "update message" required: false default: "Updated via update-coder-template action" - create: - description: "Creates a new template if it does not exist" - required: false - default: "true" dry_run: description: "Dry run" required: false @@ -57,5 +53,4 @@ runs: CODER_TEMPLATE_VERSION_NAME: ${{ inputs.name }} CODER_TEMPLATE_ACTIVATE: ${{ inputs.activate }} CODER_TEMPLATE_MESSAGE: ${{ inputs.message }} - CODER_TEMPLATE_CREATE: ${{ inputs.create }} CODER_TEMPLATE_DRY_RUN: ${{ inputs.dry_run }} diff --git a/push_template.sh b/push_template.sh index e209ff2..b737481 100755 --- a/push_template.sh +++ b/push_template.sh @@ -19,11 +19,6 @@ if [ -n "${CODER_TEMPLATE_MESSAGE}" ]; then push_command+=" --message \"${CODER_TEMPLATE_MESSAGE}\"" fi -# Append --create flag to the push command if CODER_TEMPLATE_CREATE is true -if [ "${CODER_TEMPLATE_CREATE}" = "true" ]; then - push_command+=" --create" -fi - # Add version to the push command if specified if [ -n "${CODER_TEMPLATE_VERSION_NAME}" ]; then push_command+=" --name ${CODER_TEMPLATE_VERSION_NAME}"