DanRz Posted Sunday at 04:37 PM Share Posted Sunday at 04:37 PM Hey! I am using the following GitHub workflow to publish to FTP when a new tag is pushed however I need to alter it to get the tag name and update the .env file on the server with the new version... I just can't work out how to do it... on: push: tags: - '*' name: 🚀 Deploy app on new tag jobs: web-deploy: name: 🎉 Deploy runs-on: ubuntu-latest steps: - name: 🚚 Get latest code uses: actions/checkout@v3 - name: 📂 Sync files uses: SamKirkland/FTP-Deploy-Action@4.3.3 with: server: ftp.domain.com username: XXX password: ${{ secrets.ftp_pwd }} - name: 🔐 Set Env Version id: vars run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: 🔏 Write Env Version env: RELEASE_VERSION: ${{ steps.vars.outputs.tag }} run: | echo $RELEASE_VERSION echo ${{ steps.vars.outputs.tag }} Any help would be appreciated. Dan Quote Link to comment Share on other sites More sharing options...
maxxd Posted Sunday at 11:23 PM Share Posted Sunday at 11:23 PM (edited) I haven't used the SamKirkland/FTP-Deploy-Action action so I'm not sure exactly how it works, but it kinda looks like you're copying the files to the ftp server before you make the updates to the file. Use stream editor in your workflow steps to modify the .env, then place the modified files on the server. If you set up a .env.example file in the repo with a value like so: VERSION={{VERSION}} You'll be able to run this in your workflow (assuming VERSION is a variable in your repository): - run: | cp .env.example .env sed -i 's/{{VERSION}}/${{ vars.VERSION }}/g' .env Edited Sunday at 11:24 PM by maxxd Quote Link to comment Share on other sites More sharing options...
DanRz Posted Monday at 08:16 PM Author Share Posted Monday at 08:16 PM Thanks for your reply. I have managed to fix this see code below; on: push: branches: [ development ] name: 🚀 Deploy app on new tag jobs: web-deploy: name: 🎉 Deploy runs-on: ubuntu-latest steps: - name: 🚚 Get latest code uses: actions/checkout@v3 - name: 🏷️ Get Current Tag id: vars run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: 🔏 Write Tag Version env: RELEASE_VERSION: ${{ steps.vars.outputs.tag }} run: | echo $RELEASE_VERSION - name: 🗃️ Make env File uses: SpicyPizza/create-envfile@v1.3 with: envkey_APP_ENV: "live" envkey_APP_STATUS: "1" envkey_APP_VERSION: ${{ steps.vars.outputs.tag }} - name: 📂 Sync files uses: SamKirkland/FTP-Deploy-Action@4.3.3 with: server: FTPSERVER username: USERNAME password: ${{ secrets.ftp_pwd }} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.