Github Action to edit docker compose yaml files.
To include the action in a workflow in another repository, you can use the
uses
syntax with the @
symbol to reference a specific branch, tag, or commit
hash.
See action.yml
The input 'value
' accepts JSON as well as Hjson formats
attribute
and service
are optional, if both ommited, prints whole compose file
- name: Print service attribute value
id: print-value
uses: gabor-kovac/compose-editor@main
with:
inputFile: 'docker-compose.yml'
command: 'print'
service: 'mqtt'
attribute: 'ports'
steps:
- name: Edit compose
id: edit-compose
uses: gabor-kovac/compose-editor@main
with:
inputFile: 'docker-compose.yml'
command: 'set'
service: 'mqtt'
attribute: 'links'
value: "[\"service1\",\"service2\"]"
steps:
- name: Edit compose
id: edit-compose
uses: gabor-kovac/compose-editor@main
with:
inputFile: 'docker-compose.yml'
command: 'add'
service: 'mqtt'
attribute: 'links'
value: "[\"service3\"]"
steps:
- name: Edit compose
id: edit-compose
uses: gabor-kovac/compose-editor@main
with:
inputFile: 'docker-compose.yml'
command: 'delete'
service: 'mqtt'
attribute: 'links'
Use <job-id>.outputs.print
- name: Print Output
id: output
run: echo "${{ steps.edit-compose.outputs.print }}"
Use <job-id>.outputs.yml
- name: Print yml Output
id: yml
run: echo "${{ steps.edit-compose.outputs.yml }}"
Use outputFile
input to save edited file
steps:
- name: Edit compose
id: edit-compose
uses: gabor-kovac/compose-editor@main
with:
inputFile: 'docker-compose.yml'
outputFile: 'docker-compose-edited.yml'
command: 'set'
service: 'mqtt'
attribute: 'links'
value: "[\"service1\",\"service2\"]"