Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtARTs36 committed Dec 21, 2024
1 parent 2f25f6d commit 98afd85
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 63 deletions.
86 changes: 23 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,22 @@

edit-config - is console app and GitHub action for editing configuration files

## Usage
## Workflow examples based on edit-config
- [Manual release workflow with up image version](./docs/example_release_up_image_version.md)

### Release workflow with up image version in GitHub action.yaml
## Usage

<p align="center">
<img src="./docs/usage_release_1.png" />
<img src="./docs/usage_release_2.png" />
</p>
Available actions:
- Up image version
- Append: add value to array / concat string / add number

**./github/workflows/release.yaml:**
### Up image version

```yaml
name: release

permissions: write-all

on:
workflow_dispatch:
inputs:
version:
description: version
required: true
type: choice
options:
- major
- minor
- patch

jobs:
release:
name: release
runs-on: ubuntu-latest
up-image-version:
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4 # action page: <https://github.com/actions/setup-go>
with:
go-version: stable

- name: Generate next version
- name: Up image version
id: version
uses: ci-space/edit-config@master
with:
Expand All @@ -52,35 +26,21 @@ jobs:
pointer: runs.image
value: ${{ github.event.inputs.version }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image
uses: docker/build-push-action@v4 # Action page: <https://github.com/docker/build-push-action>
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/ci-space/edit-config:${{ steps.version.outputs.new-version }}
- name: Print image version
run: echo ${{ steps.version.outputs.new-version }}
```
- name: Commit changes
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add action.yaml
git commit -m "chore: update image version ${{ steps.version.outputs.new-version }} in action.yaml"
git push
### Append value to array
- name: Create Tag
uses: negz/create-tag@v1
```yaml
jobs:
append-value-to-array:
steps:
- name: Append value to array
uses: ci-space/edit-config@master
with:
version: ${{ steps.version.outputs.new-version }}
message: ''
token: ${{ secrets.GITHUB_TOKEN }}
file: users.yaml
action: append
pointer: users[0].phones
value: '123'
```
80 changes: 80 additions & 0 deletions docs/example_release_up_image_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Release workflow with up image version in GitHub action.yaml

<p align="center">
<img src="./docs/usage_release_1.png" />
<img src="./docs/usage_release_2.png" />
</p>

**./github/workflows/release.yaml:**

```yaml
name: release

permissions: write-all

on:
workflow_dispatch:
inputs:
version:
description: version
required: true
type: choice
options:
- major
- minor
- patch

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4 # action page: <https://github.com/actions/setup-go>
with:
go-version: stable

- name: Generate next version
id: version
uses: ci-space/edit-config@master
with:
file: action.yaml
action: up-image-version
pointer: runs.image
value: ${{ github.event.inputs.version }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image
uses: docker/build-push-action@v4 # Action page: <https://github.com/docker/build-push-action>
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/ci-space/edit-config:${{ steps.version.outputs.new-version }}
- name: Commit changes
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add action.yaml
git commit -m "chore: update image version ${{ steps.version.outputs.new-version }} in action.yaml"
git push
- name: Create Tag
uses: negz/create-tag@v1
with:
version: ${{ steps.version.outputs.new-version }}
message: ''
token: ${{ secrets.GITHUB_TOKEN }}
```

0 comments on commit 98afd85

Please sign in to comment.