{"_path":"/knowledge-base/github-workflows-actions","_draft":false,"_partial":false,"_empty":false,"title":"GitHub: Workflows and Actions","description":"","excerpt":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"github-workflows-and-actions"},"children":[{"type":"text","value":"GitHub: Workflows and Actions"}]},{"type":"element","tag":"h2","props":{"id":"introduction"},"children":[{"type":"text","value":"Introduction"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To create a new github worklfow you need to place a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"your-workflow.yml"}]},{"type":"text","value":" file inside\nthe "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".github/workflows"}]},{"type":"text","value":" folder. The .github folder should be palced at the root of your project."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"An workflow file file is made up of the following components:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name:"}]}]},{"type":"text","value":" the name of the workflow"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"on:"}]}]},{"type":"text","value":" determines which event may trigger this workflow, e.g. \""},{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"push, pull_request"}]},{"type":"text","value":"\""}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jobs:"}]}]},{"type":"text","value":" the list of jobs to be executed."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"runs-on:"}]}]},{"type":"text","value":" is the name of the image of the virtual machine to be used."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"steps:"}]}]},{"type":"text","value":" each job contains a sequence of tasks called steps."}]}]},{"type":"element","tag":"h2","props":{"id":"build-your-github-workflow-for-litstack-projects"},"children":[{"type":"text","value":"Build your github workflow for litstack projects"}]},{"type":"element","tag":"h3","props":{"id":"specify-the-trigger"},"children":[{"type":"text","value":"Specify the trigger"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Start by giving your Github workflow a name and specifying which events can trigger this workflow.\nFor example, you might want to run this workflow for every single push to the repostory.\nBut you can also specify a list of branches to narrow down where the workflow should\nbe triggered on a push or pull request event."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Furthermore it's possible to tell Github to only run this workflow when a new version of\nthis repository is tagged and released."}]},{"type":"element","tag":"code","props":{"code":"name: build\n\non:\n  push:\n    branches:\n      - dev\n      - main\n  pull_request:\n    branches:\n      - main\n  release:\n    types: [published]\n\n","language":"yaml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"name: build\n\non:\n  push:\n    branches:\n      - dev\n      - main\n  pull_request:\n    branches:\n      - main\n  release:\n    types: [published]\n\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"jobs"},"children":[{"type":"text","value":"Jobs"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Once the trigger events are specified, the workflow should have something to do.\nTherefore, within the "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"jobs"}]},{"type":"text","value":", we configure a basic setup with a standard Ubuntu\nserver and set up the first "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"steps"}]}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"checkout our currently used repository"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"setting up our required php version (and composer)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"install the composer and npm dependencies."}]}]},{"type":"element","tag":"code","props":{"code":"jobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n","language":"yaml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"jobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"listack-sponsorware-packages"},"children":[{"type":"text","value":"Listack Sponsorware packages"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If your project contains any of litstacks sponserware packages (bladesmith, pages, etc.) it is required\nto provide credentials to store.litstack.io. Those are usally  stored within your auth.json file\nand thus not commited to the git."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"So to get composer to install these pacakges we need to define the credentials within the "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"repository secrets"}]},{"type":"text","value":".\nGo to the settings of your project, and  set up "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"two"}]},{"type":"text","value":" new repository secrets and fill them with the corresponding values:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"LITSTACK_USERNAME"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"LITSTACK_PASSWORD"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This allows us to use these values like this "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"${{ secrets.LITSTACK_USERNAME }}"}]},{"type":"text","value":" within the workflow, but without actually exposing them."}]},{"type":"element","tag":"h3","props":{"id":"build"},"children":[{"type":"text","value":"Build"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now that the required packages and npm dependencies are installed, we are able to "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"run a\nthe npm production build!"}]}]},{"type":"element","tag":"code","props":{"code":"      - name: Make production build\n        run: npm run production\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"      - name: Make production build\n        run: npm run production\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now, this does not have any real effect yet, because it happens on the\nvirtual machine on which the workflow is running. So we have to make a new commit from the\nvirtual machine and push it back to the repository. We authenticate the commit by\nproviding an automatically generated "},{"type":"element","tag":"a","props":{"href":"https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GITHUB_TOKEN"}]},{"type":"text","value":".\nTo make it clear that this commit was made by the CI, we specify the aw-ci-bot as its co-author."}]},{"type":"element","tag":"code","props":{"code":"      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"final-example-script"},"children":[{"type":"text","value":"Final example Script"}]},{"type":"element","tag":"code","props":{"code":"name: build\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n      - name: Make production build\n        run: npm run production\n\n      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"name: build\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n      - name: Make production build\n        run: npm run production\n\n      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n"}]}]}]}]},"public":true,"body":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"github-workflows-and-actions"},"children":[{"type":"text","value":"GitHub: Workflows and Actions"}]},{"type":"element","tag":"h2","props":{"id":"introduction"},"children":[{"type":"text","value":"Introduction"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To create a new github worklfow you need to place a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"your-workflow.yml"}]},{"type":"text","value":" file inside\nthe "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".github/workflows"}]},{"type":"text","value":" folder. The .github folder should be palced at the root of your project."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"An workflow file file is made up of the following components:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name:"}]}]},{"type":"text","value":" the name of the workflow"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"on:"}]}]},{"type":"text","value":" determines which event may trigger this workflow, e.g. \""},{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"push, pull_request"}]},{"type":"text","value":"\""}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jobs:"}]}]},{"type":"text","value":" the list of jobs to be executed."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"runs-on:"}]}]},{"type":"text","value":" is the name of the image of the virtual machine to be used."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"steps:"}]}]},{"type":"text","value":" each job contains a sequence of tasks called steps."}]}]},{"type":"element","tag":"h2","props":{"id":"build-your-github-workflow-for-litstack-projects"},"children":[{"type":"text","value":"Build your github workflow for litstack projects"}]},{"type":"element","tag":"h3","props":{"id":"specify-the-trigger"},"children":[{"type":"text","value":"Specify the trigger"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Start by giving your Github workflow a name and specifying which events can trigger this workflow.\nFor example, you might want to run this workflow for every single push to the repostory.\nBut you can also specify a list of branches to narrow down where the workflow should\nbe triggered on a push or pull request event."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Furthermore it's possible to tell Github to only run this workflow when a new version of\nthis repository is tagged and released."}]},{"type":"element","tag":"code","props":{"code":"name: build\n\non:\n  push:\n    branches:\n      - dev\n      - main\n  pull_request:\n    branches:\n      - main\n  release:\n    types: [published]\n\n","language":"yaml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"build"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#79C0FF"}},"children":[{"type":"text","value":"on"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"branches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"dev"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"main"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"pull_request"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"branches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"main"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"release"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"types"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"published"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"]"}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"jobs"},"children":[{"type":"text","value":"Jobs"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Once the trigger events are specified, the workflow should have something to do.\nTherefore, within the "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"jobs"}]},{"type":"text","value":", we configure a basic setup with a standard Ubuntu\nserver and set up the first "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"steps"}]}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"checkout our currently used repository"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"setting up our required php version (and composer)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"install the composer and npm dependencies."}]}]},{"type":"element","tag":"code","props":{"code":"jobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n","language":"yaml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"jobs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"build"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"runs-on"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"ubuntu-latest"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"steps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"checkout"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"uses"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"actions/checkout@v2"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"Setup PHP"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"uses"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"shivammathur/setup-php@v2"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"with"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"php-version"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#79C0FF"}},"children":[{"type":"text","value":"8.0"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"tools"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"composer:v2"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"coverage"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"none"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"      - "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"Install dependencies"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#7EE787"}},"children":[{"type":"text","value":"run"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C9D1D9"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF7B72"}},"children":[{"type":"text","value":"|"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#A5D6FF"}},"children":[{"type":"text","value":"          composer install --ignore-platform-reqs && npm install --non-interactive"}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"listack-sponsorware-packages"},"children":[{"type":"text","value":"Listack Sponsorware packages"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If your project contains any of litstacks sponserware packages (bladesmith, pages, etc.) it is required\nto provide credentials to store.litstack.io. Those are usally  stored within your auth.json file\nand thus not commited to the git."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"So to get composer to install these pacakges we need to define the credentials within the "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"repository secrets"}]},{"type":"text","value":".\nGo to the settings of your project, and  set up "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"two"}]},{"type":"text","value":" new repository secrets and fill them with the corresponding values:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"LITSTACK_USERNAME"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"LITSTACK_PASSWORD"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This allows us to use these values like this "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"${{ secrets.LITSTACK_USERNAME }}"}]},{"type":"text","value":" within the workflow, but without actually exposing them."}]},{"type":"element","tag":"h3","props":{"id":"build"},"children":[{"type":"text","value":"Build"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now that the required packages and npm dependencies are installed, we are able to "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"run a\nthe npm production build!"}]}]},{"type":"element","tag":"code","props":{"code":"      - name: Make production build\n        run: npm run production\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"      - name: Make production build\n        run: npm run production"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now, this does not have any real effect yet, because it happens on the\nvirtual machine on which the workflow is running. So we have to make a new commit from the\nvirtual machine and push it back to the repository. We authenticate the commit by\nproviding an automatically generated "},{"type":"element","tag":"a","props":{"href":"https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GITHUB_TOKEN"}]},{"type":"text","value":".\nTo make it clear that this commit was made by the CI, we specify the aw-ci-bot as its co-author."}]},{"type":"element","tag":"code","props":{"code":"      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\""}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"final-example-script"},"children":[{"type":"text","value":"Final example Script"}]},{"type":"element","tag":"code","props":{"code":"name: build\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n      - name: Make production build\n        run: npm run production\n\n      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\"\n","language":"yml"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"name: build\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: checkout\n        uses: actions/checkout@v2\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.0\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        run: |\n          composer config http-basic.store.litstack.io ${{ secrets.LITSTACK_USERNAME }} ${{ secrets.LITSTACK_PASSWORD }}\n          composer install --ignore-platform-reqs && npm install --non-interactive\n\n      - name: Make production build\n        run: npm run production\n\n      - name: Commit production build\n        uses: EndBug/add-and-commit@v4\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          add: \".\"\n\n          author_name: ${{ github.event.pusher.name }}\n          author_email: ${{ github.event.pusher.email }}\n\n          message: \"Apply production build from CI\n\n\n          Co-authored-by: aw-ci-bot <bot@aw-studio.de>\""}]}]}]}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"introduction","depth":2,"text":"Introduction"},{"id":"build-your-github-workflow-for-litstack-projects","depth":2,"text":"Build your github workflow for litstack projects","children":[{"id":"specify-the-trigger","depth":3,"text":"Specify the trigger"},{"id":"jobs","depth":3,"text":"Jobs"},{"id":"build","depth":3,"text":"Build"}]},{"id":"final-example-script","depth":2,"text":"Final example Script"}]}},"_type":"markdown","_id":"content:04.knowledge-base:github-workflows-actions.md","_source":"content","_file":"04.knowledge-base/github-workflows-actions.md","_extension":"md"}