I am trying to develop a Github Action to update the Version Number and DB credentials in my (mostly) php files before uploading to a FTP server.
Inside my main branch, I have a textfile called VERSION.md
with the content 2.0.1
.
The action should run on each push commit.
Before deploying to a FTP server, these substitutions are required (of course, the real repository files should not be changed, only the files which are uploaded to the server).
- For each file, the string
__VERSION__
should be replaced with the content of myVERSION.md
file. - In addition, only for the file
db_connection.php
, the string__DB-PASSWORD__
should be replaced with the corresponding secretDB_PASSWORD
.
This is my current workflow:
on: push
name: FTP Deploy
jobs:
web-deploy:
name: Ubuntu VM
runs-on: ubuntu-latest
steps:
- name: Getting latest Code
uses: actions/checkout@v2.3.2
# at this position I tried the string replacing
- name: Sync Files
uses: SamKirkland/FTP-Deploy-Action@4.0.0
with:
server: ${{ secrets.ftp_server }}
username: ${{ secrets.ftp_username }}
password: ${{ secrets.ftp_password }}
server-dir: "public_html/"
exclude: .git*
- .git*/**
- fonts/ttf/**
- symbols/**
- README.md
- VERSION.md
As a first test, I have tried
- name: Set Tokens
run: perl -pi -e 's/getString\(R\.string\.token\)/"$ENV{TOKEN}"/' 'index.php'
env:
TOKEN: ${{ secrets.TOKEN }}
to replace only for index.php
the string TOKEN
with a token stored in my secrets, but this fails. Everything looks ok, but there is no change a the server.