Replace Action
ActionsReplaces substrings in files. Useful to enrich configs with previuos steps artifacts
v2
LatestBy datamonsters
This lightweight action replaces substrings in files. It is useful for CI process when you needto update your configs depending on the previous steps results.
See action.yml
uses: datamonsters/replace-action
with:
files: 'path1/file1,path2/file2'
replacements: 'foo=bar,$FOO=Bar_Value'Consider you need to apply k8s deployment with container you've built on the previous step of you workflow.
You have a app-deployment.yaml file like this:
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: default
name: simple-app
spec:
selector:
matchLabels:
simple-app: ""
template:
metadata:
labels:
simple-app: ""
spec:
containers:
- name: simple-app
image: $IMAGE
env:
- name: HELLO_MSG
value: strangerYour workflow in this case will be like this:
name: Deploy app
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Build and push docker
id: build_step
run: |
docker build . -t ${{ secrets.AWS_ACC_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/demo:${{ github.sha }}
docker push ${{ secrets.AWS_ACC_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/demo:${{ github.sha }}
- name: Replace image in config
uses: ./.github/actions/replace
with:
files: app-deployment.yaml
replacements: '$IMAGE=${{ secrets.AWS_ACC_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/demo:${{ github.sha }}'
- name: Apply centraldashboard config
uses: steebchen/kubectl@master
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBECTL_VERSION: "1.14"
with:
args: apply -f app-deployment.yaml
The scripts and documentation in this project are released under the MIT License
Replace Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.