skip to Main Content

We succesfully use the Plesk / Github integration that deploys our developers pushes from github to our plesk stage web server using the Webhooks to have Plesk get the latest version. That works splendidly.

What we try to establish additionally is auto compile the SCSS source and submit the resulting css to our stage web server. We have added an action to the workflow but how would the compiled products end up on our stage webserver. I’m unsure if the timing in the complete workflow is right. Will the actions be performed before deployment?

This is the yaml:

on:
  push:
    branches:
      - stage


jobs:
  build_css:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout source Git branch
        uses: actions/checkout@v2
        with:
            ref: stage
            fetch-depth: 10
            submodules: true
      - name: Make destination directory for compiled CSS
        run: mkdir -vp /tmp/theme/assets/
        
      - name: Compile CSS from SCSS files
        uses: gha-utilities/[email protected]
        with:
          source: assets/src/main.scss
          destination: /tmp/theme/assets/

      - name: Move compiled CSS to path within stage branch
        run: mv /tmp/theme/assets assets/

2

Answers


  1. The GitHub Actions configuration that you have posted will perform the steps on a runner only. It will not make changes to the repository.

    To answer your question: The actions will not be performed before the deployment.

    I assume that Plesk can somehow access the latest state of the repository. If you wanted Plesk to access the compiled CSS, one way to do it is to add another step to the pipeline. This would be a step where the compiled files are committed to the repository, typically by a bot or service account. You’d have to set this up yourself.

    Example commands for the step (pseudo-code only):

      git add assets/*
      git commit -m "Add compiled files"
      git push https://$token_name:$token_value@$target
    

    Please note this may not be the best approach in general but it could help you to achieve what you want.

    Login or Signup to reply.
  2. You can do this via Plesk, through its "Additional Deployment Actions" tab. Check the Enable Additional Deployment Actions section in the Plesk documentation regarding remote Git hosting:

    In many cases, file publishing is not enough to finish web site deployment. For example, if you are using a framework like Ruby on Rails, you may need to run a data migration task after deployment with a command like this: bin/rails db:migrate.

    Plesk gives you the ability to define one or more additional commands that will be run every time the files are deployed to the web site.

    In essence, you could enter your build commands in the additional deploy actions section in Plesk:

    npm install -g sass
    mkdir -vp /tmp/theme/assets/
    sass assets/src/main.scss /tmp/theme/assets/
    mv /tmp/theme/assets assets/
    

    (Note: I’ve simply installed sass globally for this example, you may want to adapt this step depending on your usage scenario)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search