GithubHelp home page GithubHelp logo

replace-action's Introduction

replace-action

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.

Usage

See action.yml

uses: datamonsters/replace-action
with:
  files: 'path1/file1,path2/file2'
  replacements: 'foo=bar,$FOO=Bar_Value'

Example

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: stranger

Your 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

License

The scripts and documentation in this project are released under the MIT License

replace-action's People

Contributors

aszusz avatar sirmax672 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.