<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Philo on Medium]]></title>
        <description><![CDATA[Stories by Philo on Medium]]></description>
        <link>https://medium.com/@philonl?source=rss-7338a632b6fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*iUiwqHvXA9QTfqKEUcxRQQ.png</url>
            <title>Stories by Philo on Medium</title>
            <link>https://medium.com/@philonl?source=rss-7338a632b6fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:44:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@philonl/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tutorial: Multi-server artifact deployment with GitHub Actions]]></title>
            <link>https://philonl.medium.com/tutorial-multi-server-artifact-deployment-with-github-actions-1e9225de9836?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e9225de9836</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 13:30:00 GMT</pubDate>
            <atom:updated>2021-02-04T12:36:44.783Z</atom:updated>
            <content:encoded><![CDATA[<p>In the past, I’ve always used multiple third-party services to, for example, host and deploy my code to production. I like the idea of minimizing the number of third-party services as they provide overhead, potential security risks, and often additional costs. So I decided to give Github Actions a try to see if I can replicate the famous zero-downtime deployments across multiple servers. GitHub introduced GitHub Actions in 2019, a workflow automation tool that allows GitHub users to use Actions to build their continuous delivery pipelines.</p><p>As the article implies, I was able to do so 😄 Before I walk you through every step, I recommend taking a look at the free <a href="https://lab.github.com/githubtraining/github-actions:-hello-world">GitHub Actions: Hello World</a> course if you haven’t used GitHub Actions before.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2zduPKmszmI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2zduPKmszmI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2zduPKmszmI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/166059dd19459cb4ab0b4f636c257db5/href">https://medium.com/media/166059dd19459cb4ab0b4f636c257db5/href</a></iframe><h3>GitHub Action Workflow jobs overview</h3><p>Each GitHub Action workflow consists of one or multiple jobs which contain one or multiple steps. To deploy our application, we need to create the following jobs:</p><p><strong>Create GitHub Action build artifacts for deployment</strong><br>I want to create one archive containing all the code ready to be deployed on production. You could run commands like npm run production on your production server, but I like to keep my production server mean and clean. This reduces server maintenance overhead, like updating NodeJS across multiple servers.</p><p>We want to achieve the following for our Laravel application artifacts:</p><ol><li>Install NPM dependencies.</li><li>Compile CSS and Javascript assets.</li><li>Install Composer dependencies.</li><li>Archive our build and remove unnecessary data (e.g., node_modules).</li><li>Store our archive so we can deploy it to our servers.</li></ol><p><strong>Prepare release on all our servers</strong><br>We want to make sure our deployments are stable and reliable, meaning we don’t want one server to be updated while the second server failed. If the preparation fails on one server, we want the deployment sequence to stop.</p><p>We want the release preparation job to do the following:</p><ol><li>Ensure we have a directory that holds every release.</li><li>Ensure we have a storage directory that shares data between releases.</li><li>Ensure we have a current directory that links to the active release.</li><li>Extract our build files into our releases directory.</li></ol><p><strong>Run optional before hooks</strong><br>This is an optional feature, but I want to execute specific commands before the release is activated (e.g., chmod directories). So there needs to be a way to configure these so-called before hooks.</p><p><strong>Activate the release</strong><br>Now we are ready to activate our new release without any downtime. We can do this by changing symbolic links; this basically swaps the underlying release, which is linked to our current directory, to a new release inside our releases directory. I&#39;m running PHP FPM on my servers, so I also want to reload PHP FPM to detect the changes.</p><p><strong>Run optional after hooks</strong><br>This is an optional feature as well, but I want to execute specific commands after the release is activated to send a notification that my deployment completed for example. So there needs to be a way to configure these so-called after hooks.</p><p><strong>Cleaning up</strong><br>Given that we are uploading and extracting new releases, we take up more disk spaces after each release. To make sure we don’t end up with thousands of releases and a full disk, we need to limit the number of release artifacts living on every server.</p><h3>Project scaffolding</h3><p>To get started, you need to create a GitHub repository as testing your workflow requires you to commit and push your workflow yml file. It doesn’t matter if your chosen repository is public or private. Feel free to try and implement this with one of your existing projects. I recommend you create a separate branch for this, so your repository stays clean, and you don’t have a bunch of angry colleagues looking at you ;)</p><p>I’m using a clean Laravel 8.* installation to deploy in this demonstration, which you can download <a href="https://laravel.com/docs/8.x/installation">here</a>. Be sure to verify that everything works before you continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iVUVxlD9HyA-gxvF.png" /></figure><p>Finally, create a new workflow file; feel free to give it any name you would like and place it in the .github/workflows directory inside your project.</p><pre>name: Deploy Application<br><br>on:<br>  push:<br>    branches: [ master ]<br><br>jobs:<br>  # Magic</pre><p>As I mentioned earlier, you will probably end up committing and pushing to GitHub several times. So if you are working along with one of your existing projects, make sure you choose a different branch if you don’t want to clutter your commit history.</p><h3>Our first job: Create deployment Artifacts</h3><p>Before we have something to deploy, we need to start the build our Laravel application as we would typically do. So let’s kick off by checking out our project by using the predefined <a href="https://github.com/actions/checkout">checkout action by GitHub</a>.</p><pre># // code from earlier is ommited for clearity<br><br>jobs:<br>  create-deployment-artifacts:<br>    name: Create deployment artifacts<br>    runs-on: ubuntu-latest<br><br>  steps:<br>  - uses: actions/checkout@v2</pre><p>GitHub will checkout the code from our repository in the container; no further steps necessary. Now that we have our code, we can continue with compiling our assets.</p><pre># //<br>  steps:<br>  - uses: actions/checkout@v2<br>  <br>  - name: Compile CSS and Javascript<br>    run: |<br>      npm install<br>      npm run prod</pre><p><em>Tip: If you use a CDN to deliver your static files, be sure to implement your own solution. The front-end assets are now shared amongst all servers individually, which is not ideal. It may impact your website speed since assets could be loaded from different servers on every request depending on your load-balancer.</em></p><p>We can now continue with our back-end code. Before we can install any composer packages, we need to make sure PHP is installed first. We will use the setup-php action by <a href="https://github.com/shivammathur/setup-php">Shivam Mathur</a>, which makes this a breeze.</p><pre># //<br>  - name: Compile CSS and Javascript<br>    run: |<br>      npm ci<br>      npm run prod<br><br>  - name: Configure PHP 8.0<br>    uses: shivammathur/setup-php@master<br>    with:<br>      php-version: 8.0<br>      extensions: mbstring, ctype, fileinfo, openssl, PDO, bcmath, json, tokenizer, xml</pre><p>This will configure PHP 8.0 (I’ve started with PHP 7.4 and updated the article to PHP 8.0) and install the required extensions. If your application requires additional extensions, be sure to add them to the list. We can continue by installing our Composer dependencies.</p><pre># //<br>  - name: Configure PHP 8.0<br>     uses: shivammathur/setup-php@master<br>     with:<br>      php-version: 8.0<br>      extensions: mbstring, ctype, fileinfo, openssl, PDO, bcmath, json, tokenizer, xml<br>  - name: Composer install<br>    run: |<br>    composer install --no-dev --no-interaction --prefer-dist</pre><p>Since we are preparing to deploy to production, I’ve added the --no-dev flag. These additional packages are not required for production. In case you want to run PHPUnit before your deployment, you could either install the dependencies, run PHPUnit, and remove the dependencies or simply create a new workflow. I recommend the latter since it keeps testing and deployment logic separated.</p><p>Time to test out what we’ve got so far! Commit your code changes and push them to GitHub. Once you’ve done so, visit the Actions page (github.com/&lt;username&gt;/&lt;repository&gt;/actions)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oW-mAF1v0TOtlfDF.png" /></figure><p>You can click each job to see the execution output. If a job fails, it will show a red cross instead of a checkmark. The execution output will often provide you with the information you need to resolve the issue.</p><p>We’ve successfully compiled our front-end assets and installed our Composer dependencies. Now we need to store the results. GitHub provides an <a href="https://github.com/actions/upload-artifact">Upload-Artifact</a> helper. This will help us to share the Github Actions artifacts between jobs.</p><p>You can upload single files, multiple files, and directories. Since we just want all our files deployed, I prefer to create a TAR archive, so we have a single file to work with. You could also create a ZIP archive, but this will require installing additional software in the build container as Ubuntu doesn’t ship with the required libraries.</p><pre># //<br>  - name: Composer install<br>    run: |<br>     composer install --no-dev --no-interaction --prefer-dist<br><br>  - name: Create deployment artifact<br>    run: tar -czf app.tar.gz *</pre><p>This will create a new tar archive called app.tar.gz containing all the files, including the additional build artifacts we&#39;ve made in the previous steps.</p><p>This works just fine, but the archive now contains files we don’t need, like the node_modules directory. We only required these to run the npm run production command. Let&#39;s fix this by excluding directories from our archive.</p><pre># //<br>- name: Create deployment artifact<br>  run: tar -czf app.tar.gz --exclude=*.git --exclude=node_modules --exclude=tests *</pre><p>Our archive will now skip the .git, node_modules, and tests directories from our archive. If you have additional files that are not required to be on your production server, exclude them now. By making the archive smaller, your deployment will be quicker.</p><p>I want to change our archive’s filename so it’s easier to identify which commit our archive contains. GitHub has some global variables you can use in your .yml file, so let’s change the name to the commit hash.</p><pre># //<br>- name: Create deployment artifact<br>  env:<br>    GITHUB_SHA: ${{ github.sha }}<br>  run: tar -czf &quot;${GITHUB_SHA}&quot;.tar.gz --exclude=*.git --exclude=node_modules *es *</pre><p>We use the env option to pass environment variables down into the container. In this case, we define an environment variable called GITHUB_SHA and assign it the commit hash from the current job. If you want to know more about context and expression syntax for GitHub Actions, click <a href="https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions">here</a>.</p><p>We’re now ready to upload our build artifacts with the <a href="https://github.com/actions/upload-artifact">Upload-Artifact</a> helper.</p><pre># //<br>- name: Create deployment artifact<br>  env:<br>    GITHUB_SHA: ${{ github.sha }}<br>  run: tar -czf &quot;${GITHUB_SHA}&quot;.tar.gz --exclude=*.git --exclude=node_modules *<br><br>- name: Store artifact for distribution<br>  uses: actions/upload-artifact@v2<br>  with:<br>    name: app-build<br>    path: ${{ github.sha }}.tar.gz</pre><p>We only need to provide this step with the path to our file. We again use the GitHub Action expression to get the commit hash. Finally, we provide our artifact with a name, which we can use for later reference to download the GitHub Actions artifacts in our deployment job.</p><p>Before we can continue with any of the follow-up jobs, we need to prepare something called a GitHub Actions strategy matrix. A strategy creates a build matrix for your jobs. You can define different variations to run each job in.</p><p>You can define a matrix of different job configurations. A matrix allows you to create multiple jobs by performing variable substitution in a single job definition.</p><p>In our case, servers are the variable in our jobs. We we will use a JSON file inside our repository, so we don’t have to switch back and forth between the GitHub UI.</p><p>Create a new file called deployment-config.json in the root of your project and add the following contents:</p><pre>[<br>  {<br>    &quot;name&quot;: &quot;server-1&quot;,<br>    &quot;ip&quot;: &quot;123.456.78.90&quot;,<br>    &quot;username&quot;: &quot;web&quot;,<br>    &quot;port&quot;: &quot;22&quot;,<br>    &quot;beforeHooks&quot;: &quot;&quot;,<br>    &quot;afterHooks&quot;: &quot;&quot;,<br>    &quot;path&quot;: &quot;&quot;<br>  }<br>]</pre><p>This file contains a list of all our servers we wish to deploy to. We can define the before and after hook, and our Nginx directory path, which will serve our application for each server. For authentication we will use an SSH key which you can store inside a <a href="https://docs.github.com/en/actions/reference/encrypted-secrets">repository secret</a>. In this example I will name the secret SSH_KEY and reference this secret inside our workflow to authenticate the commands we want to execute on our remote server .</p><p>You could even host this file somewhere to dynamically populate this file, so if you add more instances to your infrastructure, they will be automatically included in the deployment cycle.</p><p><em>Note: A job matrix can generate a maximum of 256 jobs per workflow run. If you want to deploy to hundreds of servers in a single workflow, you need an alternative. I would recommend going serverless with a solution like </em><a href="https://vapor.laravel.com/"><em>Laravel Vapor</em></a><em>.</em></p><p>To make this configuration available inside our GitHub Actions workflow, we need to export this data. Using a special syntax, GitHub can identify which data to assign to which variable to reference later on our workflow matrix.</p><pre># //<br>- name: Store artifact for distribution<br>  uses: actions/upload-artifact@v2<br>  with:<br>    name: app-build<br>    path: ${{ github.sha }}.tar.gz<br><br>- name: Export deployment matrix<br>  id: export-deployment-matrix<br>  run: |<br>    JSON=&quot;$(cat ./deployment-config.json)&quot;<br>    JSON=&quot;${JSON//&#39;%&#39;/&#39;%25&#39;}&quot;<br>    JSON=&quot;${JSON//$&#39;\n&#39;/&#39;%0A&#39;}&quot;<br>    JSON=&quot;${JSON//$&#39;\r&#39;/&#39;%0D&#39;}&quot;<br>    echo &quot;::set-output name=deployment-matrix::$JSON&quot;</pre><p>First, we need to get the JSON from our deployment-config.json by using a simple cat command. Next, we will escape the JSON (only required if your JSON is multiple lines). Finally, we use the ::set-output syntax to tell GitHub which value we want to associate with the deployment-matrix key, ::set-output name= <strong>deployment-matrix</strong>::$JSON.</p><p>If we want our other jobs to get the output from this job, we need to specify the output reference in our create-deployment-artifacts job.</p><pre># //<br>jobs:<br>  create-deployment-artifacts:<br>    name: Create deployment artifacts<br>    runs-on: ubuntu-latest<br>    outputs:<br>      deployment-matrix: ${{ steps.export-deployment-matrix.outputs.deployment-matrix }}<br>    steps:<br>      - uses: actions/checkout@v2<br><br># //</pre><p>We can now reference deployment-matrix in other jobs and get all the required information for each of our servers.</p><h3>Our second job: Prepare the release on all the servers</h3><p>Next up, we can continue to prepare our release on every server. Thanks to the deployment matrix configuration we’ve created, we can cycle through each server to repeat all the steps on every server.</p><pre># //<br>prepare-release-on-servers:<br>  name: &quot;${{ matrix.server.name }}: Prepare release&quot;<br>  runs-on: ubuntu-latest<br>  needs: create-deployment-artifacts<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}</pre><p>As you can see, there are a couple of new parameters. The first new parameter, needs, allows us to make sure a specific step has finished before this job can start. In our case, we want to prepare the release on the servers once the create-deployment-artifacts. If you have multiple step dependencies, you can also pass an array.</p><p>Next, we got our strategy parameter, which allows us to define our matrix. In this case, we define a matrix variable named server and assign it to our deployment-matrix we&#39;ve created in our previous job. By default, the <a href="https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix">build matrix</a> expects an array and not a JSON string.</p><p>As mentioned earlier, GitHub Actions <a href="https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions">support context and expression syntax</a> to access context information but also to evaluate expressions. This includes a couple of <a href="https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#functions">functions</a> to, for example, cast values. To read our server configuration, we need to change our JSON string into a real JSON object using the <a href="https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#fromjson">fromJSON</a> function.</p><p>We can retrieve our JSON object through the matrix context. This enables access to the matrix parameters we&#39;ve configured for the current job. For example, in the code above, you can see we define a variable job name: name: &quot;${{ matrix.server.name }}: Prepare release&quot;. In the GitHub UI, this will resolve to &quot;server-1: Prepare release&quot;.</p><p>We are now ready to continue with the steps of our job, downloading our artifact to our build container, uploading our artifact to the server, extracting our archive, and set up required directories on our server if they don’t exist.</p><pre># //<br>prepare-release-on-servers:<br>  name: &quot;${{ matrix.server.name }}: Prepare release&quot;<br>  runs-on: ubuntu-latest<br>  needs: create-deployment-artifacts<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}<br>  steps:<br>    - uses: actions/download-artifact@v2<br>      with:<br>        name: app-build<br>    - name: Upload<br>      uses: appleboy/scp-action@master<br>      with:<br>        host: ${{ matrix.server.ip }}<br>        username: ${{ matrix.server.username }}<br>        key: ${{ secrets.SSH_KEY }}<br>        port: ${{ matrix.server.port }}<br>        source: ${{ github.sha }}.tar.gz<br>        target: ${{ matrix.server.path }}/artifacts</pre><p>We start by downloading our GitHub Actions build artifact, which is quite simple as GitHub provides a simple action out of the box called “ <a href="https://github.com/actions/download-artifact">Download Artifact</a> s.” We reference the name we’ve used for uploading our artifact. This will download the artifact into the build container.</p><p>Next, we upload the artifact to the server using a third-party <a href="https://github.com/appleboy/scp-action">SCP</a> action in the GitHub Actions marketplace. This action will copy our file via SSH based on our configuration. Make sure to check out the <a href="https://github.com/appleboy/scp-action">repository</a> for all available input variables for this action if you, for example, want to use SSH keys for authentication.</p><p>The SSH credentials are self-explanatory; we simply reference our JSON object to get the server’s connection details and the credentials. The SCP action requires a source input variable; this is the file we want to upload. We use the commit hash context object again to generate the filename ${{ github.sha }}.tar.gz.</p><p>Besides the source input variable, we also need to provide the target input variable. I want to keep all the uploaded artifacts in a separate directory. I reference the server path and append the path with the directory name artifacts to achieve this. The final path will be /var/www/html/artifacts.</p><p>Let’s take a look and make sure everything is working so far. Commit all your changes and push them to GitHub. Visit the actions page of your repository again, and you should see a running action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*doxngPRVKEP-GRoHvY-zdw.png" /><figcaption>GitHub Actions Job Results and Artifacts</figcaption></figure><p>Click the <strong>server-1: Prepare release</strong> job so you can see the output of all the steps. Click on the <strong>Upload</strong> job to expand the output. Seems to be looking good so far, our GitHub Actions release artifacts are now uploaded to our remote server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNlkKsCU44EtCvTmKr6d-w.png" /><figcaption>GitHub Actions Job Output</figcaption></figure><p>Our final step for this job is to extract our uploaded archive and create a couple of directories if they don’t exist. We will use SSH commands to set this up. We will again use a third-party action in the GitHub Actions marketplace called <a href="https://github.com/appleboy/ssh-action">SSH Action</a>. By now, you will be familiar with most of the syntax. The input variables are similar to the previous upload step:</p><pre># //<br>- name: Extract archive and create directories<br>  uses: appleboy/ssh-action@master<br>  env:<br>    GITHUB_SHA: ${{ github.sha }}<br>  with:<br>    host: ${{ matrix.server.ip }}<br>    username: ${{ matrix.server.username }}<br>    key: ${{ secrets.SSH_KEY }}<br>    port: ${{ matrix.server.port }}<br>    envs: GITHUB_SHA<br>    script: |<br>      mkdir -p &quot;${{ matrix.server.path }}/releases/${GITHUB_SHA}&quot;<br>      tar xzf ${{ matrix.server.path }}/artifacts/${GITHUB_SHA}.tar.gz -C &quot;${{ matrix.server.path }}/releases/${GITHUB_SHA}&quot;<br>      rm -rf ${{ matrix.server.path }}/releases/${GITHUB_SHA}/storage<br><br>      mkdir -p ${{ matrix.server.path }}/storage/{app,public,framework,logs}<br>      mkdir -p ${{ matrix.server.path }}/storage/framework/{cache,sessions,testing,views}<br>      chmod -R 0777 ${{ matrix.server.path }}/storage</pre><p>If you use the | character in your script, you can define multiple commands split across multiple lines you want to execute on your server.</p><pre># Create a new directory with the commit hash as the directory name<br>mkdir -p &quot;${{ matrix.server.path }}/releases/${GITHUB_SHA}&quot;<br><br># Extract the tar file into our release directory<br>tar xzf ${{ matrix.server.path }}/artifacts/${GITHUB_SHA}.tar.gz -C &quot;${{ matrix.server.path }}/releases/${GITHUB_SHA}&quot;<br><br># Create Laravel storage directories and set permissions<br>mkdir -p ${{ matrix.server.path }}/storage/{app,public,framework,logs}<br>mkdir -p ${{ matrix.server.path }}/storage/framework/{cache,sessions,testing,views}<br>chmod -R 0777 ${{ matrix.server.path }}/storage</pre><p>If you want, you can SSH into one of your servers and verify that the directories exist and the archive is unarchived.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*vgQ4F_N4SrFK4xSPXICs_A.png" /><figcaption>GitHub Actions job result manual verification via SSH</figcaption></figure><p>So far, so good! We’ve made our build, uploaded the results to our server, extracted the archive, and made sure the required directories exist. We are almost there :)</p><h3>Our third job: Run before hooks</h3><p>This step is optional, but it’s quite useful if you want to execute specific commands before you activate your release. In this example, we are using Laravel, so you might want to run database migrations.</p><pre># //<br>run-before-hooks:<br>  name: &quot;${{ matrix.server.name }}: Before hook&quot;<br>  runs-on: ubuntu-latest<br>  needs: [ create-deployment-artifacts, prepare-release-on-servers ]<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}<br>  steps:<br>  - name: Run before hooks<br>    uses: appleboy/ssh-action@master<br>    env:<br>      GITHUB_SHA: ${{ github.sha }}<br>      RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}<br>      ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current<br>      STORAGE_PATH: ${{ matrix.server.path }}/storage<br>      BASE_PATH: ${{ matrix.server.path }}<br>    with:<br>      host: ${{ matrix.server.ip }}<br>      username: ${{ matrix.server.username }}<br>      key: ${{ secrets.SSH_KEY }}<br>      port: ${{ matrix.server.port }}<br>      envs: envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH<br>      script: |<br>        ${{ matrix.server.beforeHooks }}</pre><p>Again, similar job but with a couple of changes. First, we want to make sure the create-deployment-artifacts and the prepare-release-on-servers have been completed by passing an array to the need property.</p><pre>needs: [ create-deployment-artifacts, prepare-release-on-servers ]</pre><p>To make things a bit easier when defining before hooks, I want to use specific environment variables to simplify things. Let’s say I want to execute set permissions on the storage directory:</p><pre>[<br>  {<br>    &quot;name&quot;: &quot;server-1&quot;,<br>    &quot;beforeHooks&quot;: &quot;chmod -R 0777 ${RELEASE_PATH}/storage&quot;,<br>    &quot;afterHooks&quot;: &quot;&quot;,<br>    &quot;path&quot;: &quot;/var/www/html&quot;<br>  }<br>]</pre><p>To make these environment variables available, you need to explicitly define which variables you want to pass via the envs input variable.</p><h3>Our fourth job: Activating the release</h3><p>Time for the most exciting part, if I say so myself, activating our release. We will re-use a big chunk of our previous step with a couple of changes.</p><pre># //<br>activate-release:<br>  name: &quot;${{ matrix.server.name }}: Activate release&quot;<br>  runs-on: ubuntu-latest<br>  needs: [ create-deployment-artifacts, prepare-release-on-servers, run-before-hooks ]<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}<br>  steps:<br>    - name: Activate release<br>      uses: appleboy/ssh-action@master<br>      env:<br>        GITHUB_SHA: ${{ github.sha }}<br>        RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}<br>        ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current<br>        STORAGE_PATH: ${{ matrix.server.path }}/storage<br>        BASE_PATH: ${{ matrix.server.path }}<br>        LARAVEL_ENV: ${{ secrets.LARAVEL_ENV }}<br>      with:<br>        host: ${{ matrix.server.ip }}<br>        username: ${{ matrix.server.username }}<br>        key: ${{ secrets.SSH_KEY }}<br>        port: ${{ matrix.server.port }}<br>        envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH,ENV_PATH,LARAVEL_ENV<br>        script: |<br>          printf &quot;%s&quot; &quot;$LARAVEL_ENV&quot; &gt; &quot;${BASE_PATH}/.env&quot;<br>          ln -s -f ${BASE_PATH}/.env $RELEASE_PATH<br>          ln -s -f $STORAGE_PATH $RELEASE_PATH<br>          ln -s -n -f $RELEASE_PATH $ACTIVE_RELEASE_PATH<br>          service php8.0-fpm reload</pre><p>Again, we update the need input variable to include all previous steps before running the activate-release job:</p><pre>needs: [ create-deployment-artifacts, prepare-release-on-servers, run-before-hooks ]</pre><p>I’ve added a new Laravel environment variable, LARAVEL_ENV, which will contain the environment variable for our Laravel application. This variable doesn&#39;t contain any data just yet. So let&#39;s do this first, you can define key-value secrets per repository via the GitHub UI (repository-&gt;settings -&gt;secrets)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*ORZOLt6Bz7J2BplMPnwFWQ.png" /><figcaption>GitHub Repository Secrets</figcaption></figure><p>Let’s take a closer look at our bash script line by line:</p><pre># Store the environment data to the /var/www/html/.env file <br>printf &quot;%s&quot; &quot;$LARAVEL_ENV&quot; &gt; &quot;${BASE_PATH}/.env&quot;<br><br># Link /var/www/html/.env file to /var/www/html/releases/633be605b03169ef96c2cee1f756852e1ceb2688/.env<br>ln -s -f ${BASE_PATH}/.env $RELEASE_PATH<br><br># Link /var/www/html/storage directory to /var/www/html/releases/633be605b03169ef96c2cee1f756852e1ceb2688/storage<br>ln -s -f $STORAGE_PATH $RELEASE_PATH<br><br># Link the release path to the active release path, /var/www/html/current -&gt; /var/www/html/releases/633be605b03169ef96c2cee1f756852e1ceb2688<br>ln -s -n -f $RELEASE_PATH $ACTIVE_RELEASE_PATH<br><br># Reload php8.0 to detect file changes<br>service php8.0-fpm reload</pre><p><em>Tip: There is a minor delay between the activation and the after hook job. So make sure to include critical commands in the activation job. You could add an extra release hook configuration if you want to define this per server.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OnGoHT5XZD4tsPMq.png" /></figure><p>Taking a quick look at all the directories via SSH verifies shows that everything is working correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*pSxoYX_VolXSGEiK.png" /></figure><p>The current directory is pointing to /var/www/html/releases/5b62b9a13...</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*tSD0ToW4cVzCzXfC.png" /></figure><p>The current release environment file /var/www/html/current/.env is pointing to /var/www/html/.env and /var/www/html/current/storage is pointing to /var/www/html/storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*96UmhAjRQidvCQy9.png" /></figure><p>Our Laravel application is up and running with zero downtime! Hurray!</p><h3>Our fifth job: After hook</h3><p>Our after hook is exactly the same as our before hook besides a few naming changes:</p><pre># //<br>run-after-hooks:<br>  name: &quot;${{ matrix.server.name }}: After hook&quot;<br>  runs-on: ubuntu-latest<br>  needs: [ create-deployment-artifacts, prepare-release-on-servers, run-before-hooks, activate-release ]<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}<br>  steps:<br>    - name: Run after hooks<br>      uses: appleboy/ssh-action@master<br>      env:<br>        GITHUB_SHA: ${{ github.sha }}<br>        RELEASE_PATH: ${{ matrix.server.path }}/releases/${{ github.sha }}<br>        ACTIVE_RELEASE_PATH: ${{ matrix.server.path }}/current<br>        STORAGE_PATH: ${{ matrix.server.path }}/storage<br>        BASE_PATH: ${{ matrix.server.path }}<br>      with:<br>        host: ${{ matrix.server.ip }}<br>        username: ${{ matrix.server.username }}<br>        key: ${{ secrets.SSH_KEY }}<br>        port: ${{ matrix.server.port }}<br>        envs: GITHUB_SHA,RELEASE_PATH,ACTIVE_RELEASE_PATH,STORAGE_PATH,BASE_PATH<br>        script: |<br>          ${{ matrix.server.afterHooks }}</pre><p>Again the needs input variable is updated to make sure all previous steps have been completed.</p><h3>Our sixth job: Cleaning up</h3><p>Every release we upload and extract on our production servers take up space. You don’t want to end up having servers meltdown because of their hard drives being full. So let’s clean up after each deployment and keep 5 releases.</p><pre>clean-up:<br>  name: &quot;${{ matrix.server.name }}: Clean up&quot;<br>  runs-on: ubuntu-latest<br>  needs: [ create-deployment-artifacts, prepare-release-on-servers, run-before-hooks, activate-release, run-after-hooks ]<br>  strategy:<br>    matrix:<br>      server: ${{ fromJson(needs.create-deployment-artifacts.outputs.deployment-matrix) }}<br>  steps:<br>    - name: Run after hooks<br>      uses: appleboy/ssh-action@master<br>      env:<br>        RELEASES_PATH: ${{ matrix.server.path }}/releases<br>        ARTIFACTS_PATH: ${{ matrix.server.path }}/artifacts<br>      with:<br>        host: ${{ matrix.server.ip }}<br>        username: ${{ matrix.server.username }}<br>        key: ${{ secrets.SSH_KEY }}<br>        port: ${{ matrix.server.port }}<br>        envs: RELEASES_PATH<br>        script: |<br>          cd $RELEASES_PATH &amp;&amp; ls -t -1 | tail -n +6 | xargs rm -rf<br>          cd $ARTIFACTS_PATH &amp;&amp; ls -t -1 | tail -n +6 | xargs rm -rf</pre><p>Let’s take closer look at the commands we are executing:</p><pre>cd $RELEASES_PATH &amp;&amp; ls -t -1 | tail -n +6 | xargs rm -rf<br>cd $ARTIFACTS_PATH &amp;&amp; ls -t -1 | tail -n +6 | xargs rm -rf</pre><p>This will cd into our release and artifacts directory, list all files in given directory, order the list by timestamp, return the results with the offset of 5 entries, and finally remove given files or folders.</p><h3>Multi-server deployment</h3><p>To deploy to multiple servers, you only need to update your deployment-config.json to include the additional servers:</p><pre>[<br>  {<br>    &quot;name&quot;: &quot;server-1&quot;,<br>    &quot;ip&quot;: &quot;123.456.78.90&quot;,<br>    &quot;username&quot;: &quot;web&quot;,<br>    &quot;port&quot;: &quot;22&quot;,<br>    &quot;beforeHooks&quot;: &quot;&quot;,<br>    &quot;afterHooks&quot;: &quot;&quot;,<br>    &quot;path&quot;: &quot;/var/www/html&quot;<br>  },<br>  {<br>    &quot;name&quot;: &quot;server-2&quot;,<br>    &quot;ip&quot;: &quot;901.234.56.78&quot;,<br>    &quot;username&quot;: &quot;web&quot;,<br>    &quot;port&quot;: &quot;22&quot;,<br>    &quot;beforeHooks&quot;: &quot;&quot;,<br>    &quot;afterHooks&quot;: &quot;&quot;,<br>    &quot;path&quot;: &quot;/var/www/html&quot;<br>  }  <br>]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Pcr0jQLN68vH-ek7hOfKdw.png" /><figcaption>Release activation on multiple servers</figcaption></figure><p>That’s a wrap! You’ve successfully made a release artifact from your application build and deployed it to multiple servers without any downtime!</p><p>I’d love to hear if you use this workflow to deploy your application, if you are happy with the results, which steps you’ve implemented or skipped, and the modifications/improvements you’ve made. Drop me a tweet <a href="https://twitter.com/philo01">@Philo01</a> and talk! 🙌🏼</p><p><em>Originally published at </em><a href="https://philo.dev/how-to-use-github-actions-build-matrix-to-deploy-artifacts-to-multiple-servers/"><em>https://philo.dev</em></a><em> on January 25, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e9225de9836" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Electron auto update introduction]]></title>
            <link>https://philonl.medium.com/electron-auto-update-introduction-7d4d3edca452?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d4d3edca452</guid>
            <category><![CDATA[electron-app]]></category>
            <category><![CDATA[auto-update]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Wed, 13 Jan 2021 17:35:00 GMT</pubDate>
            <atom:updated>2021-01-16T10:49:43.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjfT0uxExYqwBfHjbJVajw.jpeg" /></figure><p>You’ve just completed building your Electron application; everything is working so far; it’s <a href="https://philo.dev/notarizing-your-electron-application/">notarized</a> to work on macOS, and you’ve tested your application on Windows and Linux as well. You shared your application with the world and got some great responses from your community. Eventually, more and more messages appear in your inbox about your app crashing. You discovered a bug in your application that was causing the crashes and quickly fixed it. But how do you get this new version of your application out to your users?</p><h3>Introducing Electron Auto Update</h3><p>Electron ships with an auto-update feature so you can quickly ship updates of your product to your users. When I implemented the auto update feature in my <a href="https://philo.dev/introducing-artisan-remote/">first Electron application</a>, I went down the rabbit hole to figure out how the Electron auto-update feature works because it wasn’t that straightforward, in my opinion.</p><p>A few things that you should know about Electron auto update:</p><ul><li>It only supports macOS and Windows (no support for Linux).</li><li>Both the macOS and Windows updater use <a href="https://github.com/Squirrel">Squirrel</a> behind the scenes.</li><li>The Windows version of Squirrel is looking for maintainers to “reboot” the project and has over 300 issues, meaning you might expect some problems.</li><li>You must sign your application on macOS for the auto-updater to work.</li><li>You must <a href="https://www.electronjs.org/docs/api/app#appmovetoapplicationsfolderoptions-macos">move your application</a> to the `Applications` directory on macOS for the auto-updater to work.</li><li>On Windows, make sure you <a href="https://github.com/electron/windows-installer#handling-squirrel-events">don’t update your application</a> on its first run, or your app will throw a very user <a href="https://github.com/electron/electron/issues/7155">unfriendly error</a>.</li></ul><h3>Configuring Electron Auto Update</h3><p>Implementing Electron Auto Update is relatively easy; it only requires a few lines of code to integrate with your deployment server.</p><pre>const { app, autoUpdater } = require(&#39;electron&#39;)<br>autoUpdater.setFeedURL(&#39;<a href="https://dist.unlock.sh/v1/electron/my-app&#39;">https://dist.unlock.sh/v1/electron/my-app&#39;</a>)<br>autoUpdater.checkForUpdates()</pre><p>In case you want to check for updates on a regular interval (the code above only executes on startup), you can use setInterval to check every 30 minutes for example:</p><pre>setInterval(() =&gt; {<br>  autoUpdater.checkForUpdates()<br>}, 30000)</pre><p>The update will be downloaded in the background and installed automatically when the application is restarted (most of the time, see troubleshooting for some exceptions).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*LeQWR2X0FPhFGwlGAp5Ufw.png" /><figcaption>Native update notification</figcaption></figure><p>If you want to make your users aware that a new update has been downloaded and is available to be installed, you can also use autoUpdater.checkForUpdatesAndNotify() instead. The notification will be native to your user’s operating system.</p><p><em>Do you want to learn step by step how to release updates for your public repository? Be sure to check out the section below about Electron auto update for public repositories. I will publish an article in the near future about using a different server for private repositories.</em></p><h3>Implementing your Electron Auto Update notification</h3><p>If you want to use your own in-app update notification instead, you can do this by listening to the update-downloaded event emitted by the auto-updater.</p><pre>autoUpdater.on(&#39;update-downloaded&#39;, (event, releaseNotes, releaseName) =&gt; {<br>  //<br>})</pre><p><em>releaseName is only available on Windows.</em></p><p>If you want to force the auto-updater to install your update immediately after the update has been downloaded, you can use autoUpdater.quitAndInstall():</p><pre>autoUpdater.on(&#39;update-downloaded&#39;, (event, releaseNotes, releaseName) =&gt; {<br>   autoUpdater.quitAndInstall()<br>})</pre><p>Please note that your users might not appreciate this, as work could be lost when your app just quits while they were just filling out a form.</p><h3>Electron auto update for public repositories</h3><p>If your code repository is publicly available on GitHub, you can use a free service by Electron to ship your updates. It’s an easy process. Let’s quickly scaffold an application to test this out. I’m using Electron Forge’s starting template; if you want to follow along, execute the following command:</p><pre>// Yarn<br>yarn create electron-app auto-update-example</pre><pre>// NPM<br>npx create-electron-app auto-update-example</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dHSyJupdaPurLuDv.png" /></figure><p>To use the public auto-updater, we need to download the NPM dependency, so be sure to install this dependency:</p><pre>npm install update-electron-app --save</pre><p>Now just run yarn start or npm start, and your Electron application will build and execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/0*0U8VZ7i6ZxRo7xUL.png" /></figure><p>We need a public GitHub repository, so head over to <a href="https://github.com/new">github.com/new</a> and create a repository we can use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UgOjZQ8bo5n2-RUw.png" /></figure><p>To inform the auto-updater about our repository, we need to make sure we define it in our package.json:</p><pre>{<br>  &quot;name&quot;: &quot;auto-update-example&quot;,<br>  &quot;productName&quot;: &quot;auto-update-example&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;My Electron application description&quot;,<br>  &quot;repository&quot;: &quot;<a href="https://github.com/PhiloNL/electron-hello-world">https://github.com/PhiloNL/electron-hello-world</a>&quot;,<br>  &quot;main&quot;: &quot;src/index.js&quot;,<br>  //<br>}</pre><p>Let’s open src/index.js and call the updater to check for updates every hour and notify the user when an update is available.</p><pre>app.on(&#39;ready&#39;, () =&gt; {<br>    updateApp = require(&#39;update-electron-app&#39;);</pre><pre>updateApp({<br>        // repo: &#39;PhiloNL/electron-hello-world&#39;, // defaults to package.json<br>        updateInterval: &#39;1 hour&#39;,<br>        notifyUser: true<br>    });<br>});</pre><p>Next, we need to publish our app to GitHub. Electron Forge ships with a couple of build-in publishers, including one for GitHub. To install the publisher run the following command:</p><pre>npm install <a href="http://twitter.com/electron">@electron</a>-forge/publisher-github</pre><p>We can define the configuration for different publishers in your package.json file. So let&#39;s add our GitHub configuration:</p><pre>{<br>  //...<br>  &quot;main&quot;: &quot;src/index.js&quot;,<br>  &quot;config&quot;: {<br>    &quot;forge&quot;: {<br>      &quot;packagerConfig&quot;: {},<br>      &quot;publishers&quot;: [<br>        {<br>          &quot;name&quot;: &quot;<a href="http://twitter.com/electron">@electron</a>-forge/publisher-github&quot;,<br>          &quot;config&quot;: {<br>            &quot;repository&quot;: {<br>              &quot;owner&quot;: &quot;PhiloNL&quot;,<br>              &quot;name&quot;: &quot;electron-hello-world&quot;<br>            }<br>          }<br>        }<br>      ],<br>      //...<br>    }<br>  },<br>  //...<br>}</pre><p>Now let’s publish our application to GitHub by running the publish command. The publish command requires that you set your GitHub personal access token so it can access your account. You can create a personal access token <a href="https://github.com/settings/tokens">here</a>. Make sure you keep this token secure and don’t share it with anyone.</p><p><em>Please note, from this point forward, you are required to have your application signed and notarized. To learn more about signing and notarizing your application, visit </em><a href="https://philo.dev/notarizing-your-electron-application/"><em>this</em></a><em> article.</em></p><pre>export GITHUB_TOKEN=&lt;your-token&gt;<br>yarn run publish</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZ50OGJoGQ1aqlF2pV9iCw.png" /><figcaption>First release published</figcaption></figure><p>Great, you’ve just pushed version 1.0.0 to GitHub. By default, your release is set to ‘Draft’, awaiting your final approval. So head over to your repository releases and publish your release (github.com/username/repository/releases).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8m197r5qJKq-nY9lYoe_lw.png" /><figcaption>Published release on GitHub</figcaption></figure><p>Let’s test if the updater works by publishing a new release. Open src/index.html and make a couple of changes so you can see that the application has been updated.</p><p>Next, increment the version number of your application by opening package.json and changing the version number:</p><pre>{<br>  &quot;name&quot;: &quot;auto-update-example&quot;,<br>  &quot;productName&quot;: &quot;auto-update-example&quot;,<br>  &quot;version&quot;: &quot;1.0.1&quot;,<br>  // ...<br>}</pre><p>Run yarn run publish again and head over to GitHub to publish v1.0.1 of your application. Start v1.0.0 of your application and wait for the notification :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*OnbppMMmeqSyw5KYSZNRdQ.png" /><figcaption>Update available notification</figcaption></figure><p>Click restart, and you will see the new version of your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*q8PL7uJlA5xjvVyZQAV-6g.png" /><figcaption>Application is updated to v1.0.1</figcaption></figure><p>Again, this will work on both macOS and should also work on Windows if you <a href="https://github.com/electron/windows-installer#handling-squirrel-events">handle the Squirrel events correctly</a>.</p><h3>Troubleshooting</h3><p>Since auto-updating happens behind the scenes, you have no idea what is happening, which can be quite frustrating when your application doesn’t update.</p><p>To debug what is happening in the background, you can enable the logger by passing it in the update-electron-app constructor.</p><pre>require(&#39;update-electron-app&#39;)({<br>  logger: require(&#39;electron-log&#39;)<br>})</pre><p>You will be able to find the log files in the following locations:</p><ul><li>Linux: ~/.config/{app name}/logs/{process type}.log</li><li>macOS: /Library/Logs/{app name}/{process type}.log</li><li>Windows: %USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log</li></ul><pre>[info] Checking for update<br>[info] Found version v1.0.1 (url: <a href="https://github.com/PhiloNL/electron-hello-world/releases/download/v1.0.0/auto-update-example-darwin-x64-1.0.0.zip">https://github.com/PhiloNL/electron-hello-world/releases/download/v1.0.0/auto-update-example-darwin-x64-1.0.0.zip</a>)<br>[info] Downloading update from <a href="https://github.com/PhiloNL/electron-hello-world/releases/download/v1.0.0/auto-update-example-darwin-x64-1.0.0.zip">https://github.com/PhiloNL/electron-hello-world/releases/download/v1.0.0/auto-update-example-darwin-x64-1.0.0.zip</a></pre><h3>Race condition on macOS with Squirrel updater</h3><p>In some cases, your application might require multiple restarts for the update to work if your user starts the application to quickly after quitting. This can also be the case when using autoUpdater.quitAndInstall(). I&#39;ve experienced this with Electron Builder, so I&#39;m not sure if this is also the case with Electron Forge. Still, I am assuming that since they all use the Squirrel updater, it affects any application that uses the built-in Electron updater.</p><p>After a long search, I finally found this <a href="https://github.com/electron-userland/electron-builder/issues/2317">issue</a> and this <a href="https://github.com/electron-userland/electron-builder/issues/2317#issuecomment-462808392">comment</a> with a possible solution. It’s not ideal, but it fixes the problem.</p><p>When you start your application, and the Squirrel updater has found a new update for your application, it will spawn an idle process called ShipIt. This process remains idle until you quit your application. Once your application is closed, the ShipIt process will start extracting your update and replace your application with the latest version. Depending on the size of your application and the user&#39;s machine&#39;s speed, this may take a moment.</p><p>If your application starts too quickly after quitting, meaning before the updater has completed, a new ShipIt instance will replace the process, and the update process restarts. In the meantime, the user might be confused because the app is still running on the same version.</p><p>The <a href="https://gist.github.com/dsabanin/aadfbe508a627a3e95e3f024d2e5207d">Gist</a> from the issue above resolves this problem by ensuring the ShipIt process has ended. Let’s break the code down step by step.</p><pre>const shipItProcesses = await findProcess(&#39;name&#39;, &#39;ShipIt&#39;);</pre><p>Look for an active process named ShipIt.</p><pre>if (shipItProcesses.some(f =&gt; f.cmd.includes(&#39;com.org.my-app&#39;))) {<br>  shouldRestartBeforeLaunch = true;<br>  console.debug(&#39;Waiting for auto update to finish&#39;);<br>  setTimeout(makeSureAutoUpdateFinished, 1500);<br>} else {<br> // ...<br>}</pre><p>Since a user could be running multiple Electron apps, we want to make sure the ShipIt process belongs to our app com.org.my-app. If this process exists, we wait for the application to start, so the auto-updater has a chance to finish. This check will repeat recursively until the process is gone.</p><pre>        if (shouldRestartBeforeLaunch) {<br>          try {<br>            const Electron = require(&#39;electron&#39;);<br>            Electron.app.relaunch();<br>            Electron.app.exit(0);<br>          } catch (error) {<br>            console.error(&#39;Failed to restart the app through electron&#39;, error);<br>            process.exit(1);<br>          }<br>        } else {<br>          require(&#39;./main&#39;);<br>        }</pre><p>Next, it will restart the existing app to complete the update process. These multiple restarts will cause your app to bounce a couple of times in the macOS dock, but at least you are sure your user is using the latest version of your application. Finally, it will execute the main code of your Electron application.</p><p>That’s it! You’ve successfully used Electron Auto Update together with GitHub to distribute a new version of your application to your user.</p><p><em>Do you want to know more about how to publish updates from private repositories and to license your products? Be sure to subscribe for future articles or give me a follow on </em><a href="https://twitter.com/philo01"><strong><em>Twitter</em></strong></a><em>. I appreciate the support!</em></p><p><em>Originally published at </em><a href="https://philo.dev/electron-auto-update-explained/"><em>https://philo.dev</em></a><em> on January 13, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d4d3edca452" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Notarizing your Electron application with Electron Builder]]></title>
            <link>https://philonl.medium.com/notarizing-your-electron-application-with-electron-builder-4713c081f176?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/4713c081f176</guid>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[electron]]></category>
            <category><![CDATA[desktop]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 20:00:00 GMT</pubDate>
            <atom:updated>2020-12-24T19:32:19.618Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I released my <a href="https://philo.dev/introducing-artisan-remote/">first Electron application</a>. When my application was ready to be released, it was required to have it notarized by Apple, or else nobody could use my application. Although there are quite a few articles on this matter, it still took some trial and error because I ran into a couple of problems that were not mentioned. To save others some time figuring these things out, I’ve created this walkthrough to get you started.</p><h3>Electron Builder</h3><p>I’ve used <a href="https://github.com/electron-userland/electron-builder">Electron Builder</a> together with the <a href="https://github.com/nklayman/vue-cli-plugin-electron-builder">Electro Builder Vue CLI</a> to build my first application. According to the official Electron website, it’s described as a “complete solution to package and build a ready-for-distribution Electron app that focuses on an integrated experience.”</p><p>From my experience, Electron Builder works excellent during development, but it seems a bit buggy in regards to making your application available to the general public. I’ve experienced some issues with notarizing and publishing. So I might give <a href="https://www.electronforge.io/">Electron Forge</a> (maintained by Electron) a try for my next application to see how that works compared to Electron Builder (maintained by a third-party).</p><h3>Apple Developer Program</h3><p>In order to distribute your Electron app on macOS, you need to participate in Apple’s Developer Program, which costs $99 per year. You can sign up at <a href="https://developer.apple.com/">https://developer.apple.com</a>.</p><p>Head over to your Developer Portal and click on “Certificates, IDs &amp; Profiles.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d0o1j6A1jeU-J8B1.png" /></figure><p>Next, head over to “Certificates” and click the blue plus icon to create a new certificate. Depending on your distribution wishes, you need to select a certificate type. In this example, we will go ahead and select “Developer ID Application,” which reads, “This certificate is used to code sign your app for distribution outside of the Mac App Store.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7sJb5uM4d9F78I95.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ILTVgEvfLRT2qmTg.png" /></figure><p>Next up, we need to upload a “Certificate Signing Request.” You can create this with the Keychain Tool on your Mac. You can find this application in /Applications/Utilities</p><p>Next, choose Keychain Access &gt; Certificate Assistant &gt; Request a Certificate from a Certificate Authority. Fill out the form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*bNFSQgxFZLnKwaI7.png" /></figure><blockquote><em>User Email Address: &lt;your email address&gt;<br>Common Name: &lt;anything&gt;<br>CA Email Address: &lt;leave empty&gt;<br>Request is: Saved to disk</em></blockquote><p>This will create a new file “CertificateSigningRequest.certSigningRequest”. Head back to Apple’s Developer Portal again and upload the certificate signing request.</p><pre>Notarizing nl.philo.artisan-remote found at ./artisan-remote-app/dist_electron/mac/Artisan Remote.app<br>Error: Apple failed to notarize your application, check the logs for more info</pre><pre>Status Code: 2<br>Message: Package Invalid<br>Logs: <a href="https://osxapps-ssl.itunes.apple.com/itunes-assets/">https://osxapps-ssl.itunes.apple.com/itunes-assets/</a>...</pre><pre>{<br>  &quot;logFormatVersion&quot;: 1,<br>  &quot;jobId&quot;: &quot;cabb3b08-744a-4b94-853c-62fb7908bd25&quot;,<br>  &quot;status&quot;: &quot;Invalid&quot;,<br>  &quot;statusSummary&quot;: &quot;Archive contains critical validation errors&quot;,<br>  &quot;statusCode&quot;: 4000,<br>  &quot;archiveFilename&quot;: &quot;Artisan_Remote.zip&quot;,<br>  &quot;uploadDate&quot;: &quot;2020-12-22T22:45:50Z&quot;,<br>  &quot;sha256&quot;: &quot;3199b031a2d8819bec4ea52973a363657a8a221d81cc764c3169115cf1dda893&quot;,<br>  &quot;ticketContents&quot;: null,<br>  &quot;issues&quot;: [<br>    {<br>      &quot;severity&quot;: &quot;error&quot;,<br>      &quot;code&quot;: null,<br>      &quot;path&quot;: &quot;Artisan_Remote.zip/Artisan Remote.app/Contents/MacOS/Artisan Remote&quot;,<br>      &quot;message&quot;: &quot;The binary is not signed.&quot;,<br>      &quot;docUrl&quot;: null,<br>      &quot;architecture&quot;: &quot;x86_64&quot;<br>    },<br>    {<br>      &quot;severity&quot;: &quot;error&quot;,<br>      &quot;code&quot;: null,<br>      &quot;path&quot;: &quot;Artisan_Remote.zip/Artisan Remote.app/Contents/MacOS/Artisan Remote&quot;,<br>      &quot;message&quot;: &quot;The signature does not include a secure timestamp.&quot;,<br>      &quot;docUrl&quot;: null,<br>      &quot;architecture&quot;: &quot;x86_64&quot;<br>    },<br>        {<br>      &quot;severity&quot;: &quot;error&quot;,<br>      &quot;code&quot;: null,<br>      &quot;path&quot;: &quot;Artisan_Remote.zip/Artisan Remote.app/Contents/MacOS/Artisan Remote&quot;,<br>      &quot;message&quot;: &quot;The executable does not have the hardened runtime enabled.&quot;,<br>      &quot;docUrl&quot;: null,<br>      &quot;architecture&quot;: &quot;x86_64&quot;<br>    },<br>    //<br>}</pre><p>Unclear logfile from Apple which means you need to install your certificate.</p><p>Now download your certificate to your Mac, then double click the .cer file to install in Keychain Access. If you don’t do this, you will get some strange errors from Apple when notarizing your application, which doesn’t tell you anything useful:</p><h3>Configure after sign hook</h3><p>Electron Builder also uses <a href="https://github.com/electron/electron-notarize">Electron Notarize</a> behind the scenes. For example, this is the afterSignHook.js I&#39;m using:</p><pre>// &quot;afterSign&quot;: &quot;./afterSignHook.js&quot;,</pre><pre>require(&#39;dotenv&#39;).config();<br>const fs = require(&#39;fs&#39;);<br>const path = require(&#39;path&#39;);<br>var electron_notarize = require(&#39;electron-notarize&#39;);</pre><pre>module.exports = async function (params) {<br>    if (process.platform !== &#39;darwin&#39;) {<br>        return;<br>    }</pre><pre>console.log(&#39;afterSign hook triggered&#39;, params);</pre><pre>let appId = &#39;nl.philo.artisan-remote&#39;</pre><pre>let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);<br>    if (!fs.existsSync(appPath)) {<br>        console.log(&#39;skip&#39;);<br>        return;<br>    }</pre><pre>console.log(`Notarizing ${appId} found at ${appPath}`);</pre><pre>try {<br>        await electron_notarize.notarize({<br>            appBundleId: appId,<br>            appPath: appPath,<br>            appleId: process.env.APPLE_ID,<br>            appleIdPassword: process.env.APPLE_ID_PASSWORD,<br>        });<br>    } catch (error) {<br>        console.error(error);<br>    }</pre><pre>console.log(`Done notarizing ${appId}`);<br>};</pre><p>Make sure you adjust the appId to your app&#39;s name; the convention is country.company.appname. Finally, you need to set your Apple ID and password. It&#39;s recommended not to include your credentials in your code, so please use environment variables when possible. You can <a href="https://support.apple.com/en-au/HT204397">generate app-specific passwords</a>, so you don&#39;t need to write your personal password. Apple will provide you with something like edqv-akmn-hasr-tyui.</p><p>That should do it. You should now be able to successfully notarize your application with the npm run osx:build command.</p><p>At the time of writing Electron Builder still contains a <a href="https://github.com/electron-userland/electron-builder/issues/4299">bug</a> that causes the your-app-mac.zip file to have an unsigned copy of your application (the your-app.dmg will work just fine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*RDgzoemMRFwMKQNErAv-cw.png" /><figcaption>Due to a bug in Electron Builder, the zipped version of your app will not open.</figcaption></figure><p>Luckily <a href="https://gist.github.com/harshitsilly/a1bd5a405f93966aad20358ae6c4cec5">someone wrote</a> a workaround (I’ve made some adjustments for it to work with my Vue boilerplate):</p><pre>const path = require(&#39;path&#39;);<br>const {execSync} = require(&#39;child_process&#39;);<br>const fs = require(&#39;fs&#39;);<br>const yaml = require(&#39;js-yaml&#39;);<br>const {appBuilderPath} = require(&#39;app-builder-bin&#39;);<br>const currentWorkingDirectory = process.cwd();<br>const packageInfo = require(path.join(currentWorkingDirectory, &#39;package.json&#39;));</pre><pre>const APP_NAME = packageInfo.productName;<br>const APP_VERSION = process.argv[2] ? process.argv[2] : packageInfo.version;<br>const APP_DIST_PATH = path.join(currentWorkingDirectory, &#39;dist_electron&#39;);</pre><pre>console.log(&#39;Creating new distribution zip for MacOS.&#39;);</pre><pre>execSync(<br>    `ditto -c -k --sequesterRsrc --keepParent --zlibCompressionLevel 9 &quot;${APP_DIST_PATH}/mac/${APP_NAME}.app&quot; &quot;${APP_DIST_PATH}/${APP_NAME}-${APP_VERSION}-mac.zip&quot;`<br>);</pre><pre>console.log(&#39;Zip for MacOS has completed.&#39;);</pre><pre>const APP_GENERATED_BINARY_PATH = path.join(APP_DIST_PATH, `${APP_NAME}-${APP_VERSION}-mac.zip`);</pre><pre>module.exports = function () {<br>    try {<br>        let output = execSync(<br>            `${appBuilderPath} blockmap --input=&quot;${APP_GENERATED_BINARY_PATH}&quot; --output=&quot;${APP_DIST_PATH}/${APP_NAME}-${APP_VERSION}-mac.zip.blockmap&quot; --compression=gzip`<br>        );<br>        let {sha512, size} = JSON.parse(output);</pre><pre>const ymlPath = path.join(APP_DIST_PATH, &#39;latest-mac.yml&#39;);<br>        let ymlData = yaml.safeLoad(fs.readFileSync(ymlPath, &#39;utf8&#39;));<br>        console.log(ymlData);<br>        ymlData.sha512 = sha512;<br>        ymlData.files[0].sha512 = sha512;<br>        ymlData.files[0].size = size;<br>        let yamlStr = yaml.safeDump(ymlData);<br>        console.log(yamlStr);<br>        fs.writeFileSync(ymlPath, yamlStr, &#39;utf8&#39;);<br>        console.log(&#39;Successfully updated YAML file and configurations with blockmap.&#39;);<br>    } catch (e) {<br>        console.log(&#39;Error in updating YAML file and configurations with blockmap.&#39;, e);<br>    }<br>};</pre><p>All done! You should now be able to share your awesome app with the rest of the world. I’m working on a solution to make it easier for you to distribute your applications. If you are interested make sure you subscribe and be notified at <a href="https://unlock.sh/">Unlock</a>.</p><p><em>Originally published at </em><a href="https://philo.dev/notarizing-your-electron-application/"><em>https://philo.dev</em></a><em> on December 23, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4713c081f176" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Artisan Remote]]></title>
            <link>https://philonl.medium.com/introducing-artisan-remote-3b27aef6809e?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b27aef6809e</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[desktop-app]]></category>
            <category><![CDATA[electron]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 17:00:00 GMT</pubDate>
            <atom:updated>2020-12-22T17:16:04.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q2rXZsRbH9xn0rzk.png" /></figure><p>Over the years, I’ve SSH’ed into dozens of servers to execute Laravel Artisan commands. Creating some bash shortcuts made things a bit easier, luckily. On some occasions, though, clients did not support SSH, and in other cases, they did, but it was a terrible process of back-and-forth emails between clients and hosting providers to get things sorted.</p><p>I started to play around with Electron (build cross-platform desktop apps with JavaScript, HTML, and CSS) and had the idea to create something that would fix this issue as my first Electron project. So without further ado, I would like to introduce you to Artisan Remote, the perfect companion for your Laravel applications.</p><p>Artisan Remote is a desktop application that allows you to run artisan commands with a simple click and view the output of earlier executed commands across multiple Laravel applications.</p><p>Behind the scenes, the application utilizes HTTP endpoints to send and retrieve information from your Laravel applications. To allow Laravel artisan commands to execute commands via HTTP endpoints instead of the command line, I’ve created a <a href="https://github.com/PhiloNL/artisan-remote"><strong>simple package</strong></a> that exposes your artisan commands to the web.</p><h3>Getting started</h3><p>Open your terminal, switch to your favorite Laravel application, and install the Artisan Remote composer package:</p><pre>composer require philo/artisan-remote</pre><p>Next, you will need to publish the associated configuration file with the vendor:publish command:</p><pre>php artisan vendor:publish --provider=&quot;Philo\ArtisanRemote\ArtisanRemoteServiceProvider&quot;</pre><p>This command will place a configuration file in your Laravel application’s config directory config/artisan-remote.php. Inside the configuration file, you define which commands are available via the HTTP endpoint.</p><pre>&lt;?php<br><br>return [<br>    &#39;commands&#39;     =&gt; [<br>        \Illuminate\Foundation\Console\UpCommand::class,<br>        \Illuminate\Foundation\Console\DownCommand::class,<br>        \Illuminate\Cache\Console\ClearCommand::class,<br>    ],<br>    //<br>];</pre><p>Given the nature and possible power of commands, you can’t execute any without authentication. So Artisan Remote requires you to define at least one API authentication token. You can choose to restrict API tokens only to perform specific commands. For example, you might want to expose the up and down command to your client and give yourself access to execute the queue:restart command:</p><pre>&lt;?php<br><br>return [<br>    &#39;commands&#39;     =&gt; [<br>        \Illuminate\Foundation\Console\UpCommand::class,<br>        \Illuminate\Foundation\Console\DownCommand::class,<br>        \Illuminate\Cache\Console\ClearCommand::class,<br>    ],<br>    &#39;auth&#39;         =&gt; [<br>        &#39;c557510d-7f2d-4e69-b600-d1050e5dc896&#39; =&gt; [<br>            \Illuminate\Foundation\Console\UpCommand::class,<br>            \Illuminate\Foundation\Console\DownCommand::class,<br>            \Illuminate\Cache\Console\ClearCommand::class,<br>        ],<br>        &#39;240d4017-d7e3-4b30-8d74-6cb60816caf2&#39; =&gt; [&#39;*&#39;],<br>    ],<br>    //<br>];</pre><p>Best practices recommend using environment variables for sensitive information. So be sure to adjust your config file accordingly:</p><pre>env(&#39;MY_ARTISAN_REMOTE_API_KEY&#39;) =&gt; [&#39;*&#39;],</pre><p>For those who would like to be able to bring their application back online after running the down command ;) be sure to allow the desktop application to interact with your application when in maintenance mode by listing the API endpoint as an exception.</p><p>You can add this exception in the CheckForMaintenanceMode.php middleware in Laravel 7 or PreventRequestsDuringMaintenance.php in Laravel 8.</p><pre>/**<br>     * The URIs that should be reachable while maintenance mode is enabled.<br>     *<br>     * @var array<br>     */<br>    protected $except = [<br>        &#39;artisan-remote/*&#39;<br>    ];</pre><h3>Download and configure the desktop application</h3><p>Now it’s time for the exciting part. Click <a href="https://unlock.sh/download/a428d391-79a8-4300-b7f7-ace69518525b"><strong>here</strong></a> to download the desktop application for your operating system and launch it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_bCM_MFqi7XgMQ62.png" /></figure><p>To get started, click “Add new Laravel application.” and enter your application URL and the API token you’ve set in the artisan-remote.php configuration file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*r_cc-1pQ5aRmzTth.png" /></figure><p>That’s it! You’ve just added your first Laravel application to the Artisan Remote desktop application. To execute your first command, click on your application’s name; this will present you with an overview of the commands available per your configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*uJSQKMNaDWdqsHuD.png" /></figure><p>Click on the blue play icon on the right side of the command you would like to execute. Clicking the icon will display the available options for the command you’ve chosen. In case your command has no options, click the “Execute Command” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*CUfjDB4nYA0Yc04x.png" /></figure><p>Once the command execution finishes, a new window will pop-up with your command’s output. If you want, you can see the history of commands you’ve run earlier by clicking “Execution history” located in the cog menu.</p><p><strong>The Artisan Remote composer package and the desktop application are available for free.</strong> The desktop application source code is not available for now as I used Tailwind UI’s commercial components. Depending on the amount of interest from people, I might update the design and remove the Tailwind UI components so I can open-source the project.</p><p>Feedback is always welcome. If you want to report a bug, submit an idea, go to the <a href="https://github.com/PhiloNL/artisan-remote/issues"><strong>repository</strong></a>, and create an issue.</p><p><a href="https://unlock.sh/download/a428d391-79a8-4300-b7f7-ace69518525b"><strong>Download for Mac, Windows or Linux.</strong></a></p><p><em>Originally published at </em><a href="https://philo.dev/introducing-artisan-remote/"><em>https://philo.dev</em></a><em> on December 21, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b27aef6809e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The increasing importance of employer branding]]></title>
            <link>https://philonl.medium.com/the-increasing-importance-of-employer-branding-65c579323ff3?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/65c579323ff3</guid>
            <category><![CDATA[branding]]></category>
            <category><![CDATA[millennials]]></category>
            <category><![CDATA[recruitment]]></category>
            <category><![CDATA[employer-branding]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Tue, 10 Sep 2019 19:08:14 GMT</pubDate>
            <atom:updated>2021-01-14T10:51:15.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LciIHkgpq3z4tUHwbRXqIw.png" /></figure><p>Back in 2009, TED published a talk by Simon Sinek, and it was about something called the <a href="https://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action/up-next?language=en"><em>Golden Circle</em></a>. Simon explains how to truly differentiate your brand from your competitors by answering and communicating the following questions in this order:</p><ul><li><strong>Why</strong> — This is your organization’s purpose, cause, or belief. It’s the reason your organization exists.</li><li><strong>How</strong> — This is how your organization is going to achieve that purpose, cause, or belief.</li><li><strong>What</strong> — This is what your organization does, for example, the products and services you sell.</li></ul><p>The ‘Why’ is the foundation of having a strong value proposition that sets you apart from others. In the video, Simon said, “<em>People don’t buy what you do; they buy why you do it.</em>”. I believe this doesn’t just apply to the commercial aspect of businesses, but also the recruitment aspect and thus the importance of having a good employer brand. You can also use your ‘Why’ to create attracting EVP statements (employee value proposition). Let’s take a look at Nike for example, their EVP statement is “<em> We lead. We invent. We deliver. We use the power of sport to move the world</em>”. Before we look into some tips on how to improve your employer brand, let’s look at why this is getting increasingly important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TsRsbplEDn9nVeG-mMTd5A.jpeg" /></figure><h4>Baby boomers are retiring.</h4><p>The baby boomers generation is retiring (those who are born between 1946 and 1964). So what does this have to do with the importance of employer branding? Well, the baby boomers are currently holding many key positions, and since they are now starting to retire, these positions need to be filled. Which wouldn’t be a problem but given the fact they are beginning to be replaced by a generation with very different traits, it can have profound effects on organizations. I believe this is one of the reasons why the average hiring age of CEOs and CFOs has been going up since 2012 as organizations do their best to stick with the baby boomers as long as they can to postpone the possible effects it may have on their organization once a new generation takes over.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yyI9gEXnngQnofPAbGF9rA.png" /><figcaption>Average hire age for CEO’s and CFO’s — Crist|Kolder <a href="http://www.cristkolder.com/volatility-report/">Volatility Report</a></figcaption></figure><p>In one of my <a href="https://medium.com/@philonl/the-world-of-leadership-is-in-need-of-change-14bf8fa22bbb">previous articles</a>, I wrote about the required changes in the world of leadership when it comes to millennials. As <a href="https://medium.com/@philonl/the-world-of-leadership-is-in-need-of-change-14bf8fa22bbb">research by Gallup</a> shows that many leaders want to understand the millennials, but due to the absence of concrete answers or solutions, they stick with their existing policies. This will make it more difficult to attract talent. Let me explain to you why that is in the next section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUItmMX1gdBLya0AwsIW_Q.jpeg" /></figure><h4>Purpose and development drive the millennial generation.</h4><p>The millennials are the largest generation in the workforce, and they will continue to grow from around 50% right now to 75% in 2030, according to the U.S. Bureau of Labor Statistics. This means knowing who millennials are as people matters (or any generation for that matter). Organizations that fail to understand the value of the millennial mindset will fail to create work environments that attract and retain them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfcxYHiD8whe6M0JtbmL9Q.jpeg" /><figcaption>Millennials have <strong>very different traits</strong> compared to their predecessors like the baby boomers generation according to <a href="https://www.gallup.com/workplace/238073/millennials-work-live.aspx">How Millennials Want to Work and Live</a> by Gallup.</figcaption></figure><p>Back in the 20th-century, baby boomers didn’t necessarily need meaning in their jobs. For millennials, however, this is very different; they want to work for organizations with a purpose, a mission, and those who give particular importance to their development and not their satisfaction.</p><p>Millennials are often described as “job-hoppers”, which is correct according to <a href="https://www.gallup.com/workplace/238073/millennials-work-live.aspx">How Millennials Want to Work and Live</a> by Gallup, as it shows that 21% of millennials changed jobs back in 2016 which is more than three times the number of non-millennials. Sixty percent even said they are open to new job opportunities. One of the reasons millennials tend to “job-hop” however is because 55% feels unattached to their current role and organization. Again, to me, this is because organizations fail to understand the millennial mindset.</p><p>So to attract and retain talent from this generation, you have to adjust your employer brand accordingly as I believe <strong>people don’t work at organizations because of what the organization does; they work there because of why the organization does it.</strong></p><p>Let’s take a look at some employer branding tips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OL77-ALAjhmCsz0x91WcNg.jpeg" /></figure><h4>Be honest and transparent in your communication.</h4><p>Whether it’s your website, job postings, articles, ads, or any other type of publication, make sure you are honest and transparent. These days anyone can leave comments about your organization on social media but also websites like <a href="https://www.glassdoor.com/">Glassdoor</a>. If you hire people based on a half-truth, you and the rest of the world will hear about it. Don’t forget that negative news travels fast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GslLWQ6mIoJzZVcEKMHBcA.jpeg" /></figure><h4>Adjust the content and channels to your audience.</h4><p>Learn everything there is to know about your target audience and adjust your content accordingly. If you are looking for millennials, be sure to start with your organization’s purpose (<em>WHY</em>). Followed by how they can help make that purpose a reality; your organization’s values; what kind of development programs you offer and that you will help them every step of the way, preferably in that particular order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*m_MI3uNb-YIYKsSDBDOlDw.gif" /><figcaption>Employer Branding Advertisement by LinkedIn</figcaption></figure><p>Most millennials don’t care that much for the bells and whistles found in many workplaces these days. So I don’t recommend to make ping-pong tables and free snacks the centerpiece of your content.</p><p>Finally, knowing everything about your target audience helps you choose which platforms to distribute your content on. I recommend that you adjust the content based on the platforms that you choose. Let’s say you are looking for a marketer at either entry or medior level, and you pick LinkedIn and Snapchat as your platforms. Chances are you are more likely to find the entry-level on Snapchat and the medior level on LinkedIn. Adjusting your content to be more formal on LinkedIn and informal on Snapchat might help find your candidate.</p><p>Also, be sure to be on the lookout for new exciting channels, <a href="https://www.tiktok.com/en/">TikTok</a>, for example, might be the next Instagram, and the channel where your audience is on right now.</p><p><em>This article was originally published on </em><a href="https://philo.dev/"><em>philo.dev</em></a><em>. Head over there if you like this post and want to read others like it.</em></p><p><em>The featured image is from </em><a href="https://unsplash.com/photos/wwqRpSNBPq4"><em>Unsplash</em></a><em>. It’s just an example. I’m not affiliated with Nike, Inc.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65c579323ff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The world of leadership is in need of change.]]></title>
            <link>https://philonl.medium.com/the-world-of-leadership-is-in-need-of-change-14bf8fa22bbb?source=rss-7338a632b6fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/14bf8fa22bbb</guid>
            <category><![CDATA[millennials]]></category>
            <category><![CDATA[purpose]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[hr]]></category>
            <category><![CDATA[coaching]]></category>
            <dc:creator><![CDATA[Philo]]></dc:creator>
            <pubDate>Thu, 29 Aug 2019 19:02:19 GMT</pubDate>
            <atom:updated>2021-01-14T10:50:47.779Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>The world of leadership requires change</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R1UvpLDXlly9kdU-TUcPDw.png" /></figure><p>Acme was going to revolutionize the renewable energy industry with their new type of solar panels and create a sustainable world. John, a 27-year-old account executive, was going to do everything he could to help Acme make this a reality. He always cared deeply about the environment, so after graduating it only made sense for him that his first job would be at Acme. Even though other companies offered John higher paychecks, he still chose Acme because he believed in what they stood for. John had a lot of fun at his new employer, he was extremely enthusiastic about his career, and he was a joy to work with. John was known for his famous jokes bringing a lot of laughter, and comfort to the people around him. So it was no surprise that both colleagues and clients liked to work with him. John worked hard for his organization, putting in long hours not because he had to but because he loved what he was doing, and he was making an impact. He felt he had a purpose.</p><p>Before we continue on how things are at Acme, let’s go back a few months before John graduated. During that time he had a few jobs. He also did a lot of volunteering like helping with cleaning up plastic at local beaches, but he also worked at the local grocery store a few evenings each week.</p><p>John’s manager at the local grocery store, Jannet, would give him a list of tasks each evening and then quickly disappear into the back office. The list of tasks always looked rushed, the handwriting was often difficult to read, and it would only contain a handful of short instructions assuming John would figure it out what to do on his own. John did his best to complete all the tasks, but sometimes he had no idea what to do, and to make matters worse, John found it difficult to ask for help, afraid of what people would think of him.</p><p>John’s friends and family noticed that John was struggling with his job at the grocery store as he often complained about how things were going. They did the best they could by giving him advice about how to handle the situation. Eventually, John took their advice and gathered the courage to go and ask Jannet for help.</p><p>On the day he was going to ask Jannet for help, he was extremely nervous thinking about what could happen. Once the moment was there, he could barely speak, but he managed to complete the sentence. “<em>Would you maybe, ehm, be able to explain, ehm, how I would do the fourth task on the list?</em>”. Jannet responded, looking down skeptical at John as if it was really that difficult to understand the tasks she gave to him. She said she had more important things to do and quickly gave some confusing instructions which didn’t help. Afraid of confronting Jannet about the fact that her instructions didn’t help he accepted her answer and went back to work.</p><p>Every week Jannet would, however, complain and become somewhat angry about the fact that John did not complete all his tasks. Since John’s last attempt to ask for help, he had become even more afraid to try it again and would just accept the negative feedback and continue. Luckily for him, there was a light at the end of the tunnel. He was about to graduate in a few weeks and start at Acme.</p><p>John, of course, also had a manager at Acme, and his name was Alex. Even though John enjoyed his work, he didn’t like Alex that much. Alex would often only show up to complain when things didn’t go according to plan just like Jannet. Alex would also never give recognition to his colleagues; he believed everyone is paid to perform, so it only made sense that your salary is your reward for doing well. Alex was also known as the <em>king of negative reinforcement</em>, focussing on people’s weaknesses rather than their strengths. Luckily for John, he had some great colleagues, and they would give each other moral support after Alex finished yelling. Funny enough all his colleagues thought the same about Alex, but no one felt safe enough to confront him about his behavior.</p><p>Let’s fast forward one and a half year.</p><p>Acme was changing and not for the better. Even though they were expanding to multiple countries, hiring many new people, and successfully disrupting the market with their solar panels, the profit motive was getting unmoored from the purpose motive. The purpose of creating a sustainable world was lost out of sight.</p><p>So even though Acme was quite successful, John was experiencing something strange. He had more difficulty getting out of bed each morning, and at work, his mind would often drift off. His energy level was lower than usual, and there was this weird vibe going around the office, he felt somewhat detached, but he couldn’t figure out what was causing it.</p><p>Meanwhile, Alex was putting more and more pressure on his team to reach unrealistic quarterly targets he defined without even discussing these with the team. To get there, they had to take on many more accounts while they already had their hands full with the current account base. Just like Jannet, Alex would quickly disappear after commanding everyone what to do. Just like when John was working at the grocery store. John and his colleagues did know what they needed to do, but they didn’t know how to. They never had to handle so many accounts, and no one was teaching them how they could pull this off. All of them knew they were having the same issues but rather than asking each other for the help they needed, they started to point fingers and blame each other for the fact they weren’t able to keep up.</p><p>To make matters worse, one of John’s best friends got very ill. During the next couple of weeks, John went out of his way to support his friend in any way he could. He would visit him before work, after work and during the weekends. The stress at home and work was starting to take a toll. He was sleeping less every week, and his performance at work was at an all-time low.</p><p>On a Monday afternoon, John came across Alex in the hallway, and Alex said to John, “<em>It’s the fourth week in a row that you haven’t reached your target. If you continue like this, I don’t think you have a future here</em>”. With everything that was happening, John felt like the rug was being pulled out from under him. It was like the whole world started to crumble around him and no one was there to help him out. John had hit rock bottom.</p><p><em>I’ll leave the rest of the story to your imagination. However, if you want to know how Alex should have responded and why his team is not functioning well? Be sure to continue reading.</em></p><p>First, let me explain what the moral of the story is and how I came about writing it.</p><p>A good friend of mine shared a link with me a few days ago, and it was a YouTube <a href="https://youtu.be/sch1yA_xFZs">video</a> with an interesting interview with Gary Vaynerchuk. Gary said something which spoke out to me. He defines two types of leaders. Namely, <strong>HR driven leaders </strong>and<strong> CFO driven leaders</strong>. Meaning you care either about <strong>people</strong> or <strong>money</strong>. The latter is the most common. Which would be fine if we would still be in the 20th century, but since we are not, let me explain why I believe the 21st-century workforce needs HR driven leaders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99XG1fInqEFBuDXYYb6PCw.jpeg" /></figure><h4>Make room for the Millennial workforce.</h4><p>In 2016 generation Y or better known as the millennials (born between 1980 and 1996), became the largest generation in the workforce, and it’s expected to be 50% of the total workforce in two years. In 2030 it will be <strong>75%</strong> according to the U.S. Bureau of Labor Statistics.</p><p>Millennials have <strong>very different traits</strong> compared to their predecessors like the baby boomers generation. Given these facts, it’s no surprise there is a lot of research on how this generation behaves. Gallup did a fantastic job at gathering insights in their “<a href="https://www.gallup.com/workplace/238073/millennials-work-live.aspx">How Millennials Want to Work and Live</a>” analysis. I’m guessing you don’t have time to read all 150 pages right now so let me point out some interesting facts:</p><ul><li>Only 29 percent are engaged while the majority of millennials, a staggering <strong>55 percent are not engaged</strong>, and 16 percent are actively disengaged, making this the least engaged generation in the workforce.</li><li>Millennials’ lack of engagement costs the U.S. economy hundreds of billions of dollars annually in lost productivity.</li><li>Millennials change jobs more often than do those of any older generation. Sixty percent are open to a different opportunity.</li><li>Millennial turnover costs the U.S. economy an estimated $30.5 billion annually.</li><li>Opportunities to learn and grow at work are highly valuable to millennials when seeking out new jobs or deciding to stay in current ones.</li><li>Millennials want to talk with their managers — and not always just about work. However, they are less comfortable approaching their managers to speak than are their older counterparts.</li></ul><p>So it’s clear something is happening, and it’s something which never happened on a scale like this before. Back in the 20th-century people would marry and get children in their early twenties, so their purpose was providing for their family. They would then simply accept a job, do their thing for years without any complaints because in return they would receive a paycheck and some benefits. If their boss asked them to jump, they would jump because they were paid to do so. For this reason many felt unattached to their job, leaving at 5 p.m. without much afterthought.</p><p>These days are over, in the 21st-century people like John care about more than just a paycheck — <strong>they want a sense of purpose</strong>. They desire to work for organizations with a purpose, a mission, and those who give particular importance to their development and not their satisfaction (meaning they don’t care about ping pong tables, fancy coffee, and free food). <strong>They don’t want bosses — they want coaches</strong>. They don’t want yearly performance reviews focused on what they have been doing wrong. They care about having managers who can coach them by having ongoing conversations, who value them as people and employees, and who help them understand and build their strengths. They also see work and life tightly integrated. With technology being one of the reasons, as everyone is always (expected to be) “on” these days. People can work remotely and not just from home, but from anywhere in the world. Technology is changing the way how we interact, communicate, and collaborate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfcxYHiD8whe6M0JtbmL9Q.jpeg" /><figcaption>The change in Leadership</figcaption></figure><h4>If you don’t understand people, you don’t understand business.</h4><p>Knowing who millennials are as people matters (or any generation for that matter). Organizations that fail to understand the value of the millennial mindset will fail to create work environments that attract and retain them. In fact, the research by Gallup also points out both many leaders and managers recognize the importance of understanding millennials given the fact baby boomers are retiring from key positions and these positions need to be filled. Which is a problem as they have no idea how to connect with this group. Many leaders try to understand the millennial workforce, but in the absence of concrete answers, solutions, and intrinsic motivation to learn this generation, many of them seem to stick with existing policies, which in turn causes many millennials to feel misunderstood as these existing policies were made for previous generations. The fact that millennials feel misunderstood is one of the reasons <strong>55 percent is not engaged</strong>. Which I find unfortunate because I see organizations fire people with great potential because “they don’t have what it takes.” Only to see a lot of these people find new jobs elsewhere and become successful. I adamantly believe organizations with a high turnover of staff should take a good look at themselves rather than blaming the employee.</p><blockquote>Purpose and development drive the millennial generation.</blockquote><p>For those who think replacing people is more manageable and cheaper, think again. According to <a href="https://www.benefitnews.com/news/avoidable-turnover-costing-employers-big">EBN</a>, it costs employers 33% of employee’s annual salary to hire a replacement if someone leaves not to mention indirect costs like knowledge lost, the time spent finding a replacement and the time new hires need to become fully functional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T82tlr0KJYCTsHo49hc5KA@2x.jpeg" /></figure><h3>Tips to become an HR driven leader.</h3><p>Given these findings, there is no denying that leaders need to change if they want their organizations to succeed and thrive. I believe that those who choose to keep leading numbers instead of people will have increasing difficulties coming years while more and more millennials join the workforce. As leaders used to be hired and fired by their bosses, but these days, however, you can simply be rejected by the people you lead. So for those who are interested in some pointers towards becoming an HR driven leader, be sure to check the following five tips.</p><h4>Have ongoing conversations and really listen to your employees.</h4><p>First, you should strive to connect with your employees every day. Treat these ongoing conversations as coaching conversations, providing your employees with an opportunity to tell you (their coach) what they need or what’s on their mind and to receive immediate feedback.</p><p>One important thing to do when you start having these conversations is to <strong>really listen </strong>instead of waiting for the other person to finish so you can tell your story. If you need help with this, I can recommend a great book called <a href="https://www.amazon.com/Just-Listen-Discover-Getting-Absolutely/dp/0814436471/">Just Listen</a> — by Mark Goulston in which he explains how to listen effectively. Because it turns out, most of us hear what others are saying, but they don’t really listen.</p><p>It would be best if you are more interested in listening to others than you impress them. I enjoy listening and observing others, but for those who are new to this, Mark Goulston provides a great tip to master the skill of being sincere and interested when listening. First, stop thinking of conversations as a tennis match. Instead think of it as a detective game, in which your goal is to learn as much about the other person as you can. Go into the conversation, knowing that there is something very interesting about the person and be determined to discover it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BScKkeVD_JE9JxuvqAYWw.jpeg" /><figcaption>Give your employees direction towards a clear common goal</figcaption></figure><h4>Live and breathe your organization’s purpose, mission, and values.</h4><p>Purpose, mission, and values (PMV) give your employees both direction and a meaningful way of working on getting there. They help them with long-term decision-making and align everyone with a clear common goal. If you don’t have a PMV right now, I recommend you to get started on defining these first thing tomorrow.</p><ul><li><strong>Purpose</strong> — Why does that goal have to be achieved? Who benefits?</li><li><strong>Mission</strong> — What big goal or outcome is your organization committed to?</li><li><strong>Values</strong> — How will your organization behave to make that happen?</li></ul><p>Don’t think you can check this off your list by simply putting these on the wall. You and your entire organization for that matter have to live and breathe the purpose, mission, and values for this to work. You can’t keep your employees accountable for any of these if you don’t hold yourself accountable. Also, don’t let profit get in the way of your organization PMV unless you want bad things to start happening.</p><blockquote>“When the profit motive gets unmoored from the purpose motive, bad things start to happen. Product and service quality often drops, employees are unhappy, and these places become uninspiring to work for”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4FmTCLA6W2DDlLcd3lZlA.jpeg" /><figcaption>Handwritten cards by the CEO of Envato</figcaption></figure><h4>Recognize big wins, small wins, and hard work</h4><p><a href="https://www.amazon.com/Build-Playbook-World-Class-Employee-Engagement/dp/1119390052">Build it — The Rebel Playbook</a> by Glenn Elliot &amp; Debra Corey is a must-read for anyone who wants to lead an organization with engaged employees. Research shows that recognition is a huge part of having engaged employees. So here is the strange thing. More than one-third (34%) of senior decision-makers don’t think that regular recognition and thanking employees at work has a significant impact on staff retention. They couldn’t be more wrong.</p><ul><li>70% of employees say that motivation and morale would improve if managers said thank you more. That’s two in every three of your employees who would be more productive if they were recognized.</li><li>50% of employees surveyed would leave a company if they weren’t regularly thanked and recognized for their efforts.</li><li>85% of employees think managers and leaders should spot good work and give praise, and thanks whenever it happens.</li></ul><p><em>— Reward Gateway Employee Recognition Survey 2017</em></p><p>Since we’re talking about leading people and not numbers the following shouldn’t be a surprise. <strong>It’s never, ever, ever all about the money. </strong>Giving monetary rewards can have a negative impact on your employees (see the video in the next section). In <em>some cases</em>, it can be motivational, but it’s the message that employees value more than anything else. Show your employees you see them as real human beings and not just an employee. Writing a personal postcard, for example, shows that you’re thinking about them as a person, adding value and meaning to their life. A personal message means so much more than a €25 gift card. To give you an example; I worked remotely for about seven years for a company called Envato, and each year, I would receive a personal handwritten card from the CEO and a small gift. Even though I was 15.000 kilometers away from their headquarters, they thought of me, and it made me feel appreciated and connected to the organization. I even still have all the cards.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fu6XAPnuFjJc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Du6XAPnuFjJc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fu6XAPnuFjJc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/edbdce212c4c00a0a2ed902efa87a2c6/href">https://medium.com/media/edbdce212c4c00a0a2ed902efa87a2c6/href</a></iframe><h4>The surprising truth about what motivates us.</h4><p>The video is an animation based on <a href="https://www.amazon.com/Drive-Surprising-Truth-About-Motivates/dp/1594484805/">Drive</a> — by Daniel Pink in which he explains the surprising truth about what motivates us. Be sure to check it out.</p><p>To answer your first question. Yes, money is a motivator, that’s a fact. If your employees have difficulties making ends meet they won’t be motivated and they will be distracted. That leaves three crucial factors, which will lead to better performance and personal satisfaction.</p><ul><li><strong>Autonomy</strong> — Our desire to be self-directed. It increases engagement over compliance. So like Steve Jobs said, “<em>It doesn’t make sense to hire</em><strong><em> </em></strong><em>smart people and tell them what to; we hire smart people so they can tell us what to do.</em><strong>”.</strong></li><li><strong>Mastery</strong> — The urge to get better skills. Make sure you give your employees the support they need to help them develop the right skills, behaviors, and mindset. A survey showed that 70% of employees said that learning opportunities directly influences their decision to stay with an organization.</li><li><strong>Purpose</strong> — The desire to do something that has meaning and is important. So make sure your organization has a purpose and let employees know what you expect of them and how this contributes to the purpose of the organization.</li></ul><p>If one or more of these three factors are not present within your organization, people will start leaving, and for those who stay, some will find their paycheck increasingly more important in order to compensate the fact they are not enjoying their time at work. Which is interesting as <strong>71% of professionals said they’d actually be willing to take a pay cut to work for an organization with a purpose they believe in and shared values </strong>according to LinkedIn. The purpose and values of Acme is the reason why John choose to work for Acme; they shared the same beliefs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*JsjaSrEQ6jyOTtbmeErVbQ.png" /><figcaption>The Five Dysfunctions of a Team</figcaption></figure><h4>Embed these five leadership principles based on The Five Dysfunctions of a Team by Patrick Lencioni.</h4><p>Patrick Lencioni is the author of the book called <a href="https://www.amazon.com/Five-Dysfunctions-Team-Leadership-Fable/dp/0787960756"><strong>The Five Dysfunctions of a Team</strong></a> <strong>and it has become the world’s most definitive source on practical information for building teams. </strong>Make sure you read this book. I promise you; you will be glad you did.</p><p>Lencioni writes about teams and looks at things from a negative perspective (the dysfunctions) teaching you how to improve your team once things are going bad. So if we look at this from a leadership perspective, you want to lead in such a way that you built teams which are healthy from the start and stay healthy without any dysfunctions.</p><p>If you take a look at the pyramid above, you will start to understand why John and his colleagues weren’t confronting Alex, why they were starting to point fingers and why things were deteriorating in general. Alex did not develop any trust because he created an unsafe environment. The lack of trust is the reason why there is a massive fear of conflict and why they choose to preserve artificial harmony. Without conflicts, you get a lack of commitment. Without commitment, you get a lack of accountability. Last but not least, without accountability, you don’t get results.</p><ul><li><strong>Absence of Trust<br></strong>The fear of being vulnerable to team members prevents the building of trust within the team.</li><li><strong>Fear of Conflict<br></strong>The desire to preserve artificial harmony stifles the occurrence of productive ideological conflict.</li><li><strong>Lack of Commitment<br></strong>The lack of clarity or buy-in prevents team members from making decisions they will stick to.</li><li><strong>Avoidance of Accountability<br></strong>The need to avoid interpersonal discomfort prevents team members from holding one another accountable.</li><li><strong>Inattention to Results<br></strong>The pursuit of individual goals and personal status erodes the focus on collective success.</li></ul><p>The book contains a questionnaire you can use to figure out which of the five dysfunctions requires attention in your team. It also has some cool exercises you can do with your team to improve any dysfunctions your team might have.</p><p><strong>The five leadership principles</strong></p><p>This article probably wouldn’t even exist if I hadn’t graduated as a <a href="http://bit.ly/327sufA">Professional Business Communicator</a> earlier this year at the Business NLP academy. This education has been a life-changing experience for me as I learned so much about myself, what it takes to be a leader, how people <em>work</em>, the importance of verbal and nonverbal communication, but it also helped me discover a new passion; helping others to get the most out of themselves. The reason I’m telling you this is because this is where I also learned the five leadership principles of a Professional Business Communicator which are based on Lencioni’s work.</p><ul><li><strong>Be vulnerable<br></strong>You know what you can do best. You also know what you definitely can’t do. Tell others timely when needed and make sure you reach out for help when you need it.</li><li><strong>Take on necessary confrontations<br></strong>Ensure true harmony and strive to enforce long-term respect.</li><li><strong>Have commitment<br></strong>Align your emotions and decisions in such a way so that they help you achieve your goals.</li><li><strong>Take your responsibility<br></strong>Be accountable. You believe the quality of your employees is in any way, a reflection of you as a leader. You attribute the positive results to your team, and you blame the shortcomings to yourself.</li><li><strong>Reach your results<br></strong>You feel that, because you are paid for it, you have an obligation to work with your employees to achieve the results that the organization needs.</li></ul><p>To wrap up things up, I want to talk about John and Alex. Alex said to John, “<em>It’s the fourth week in a row that you haven’t reached your target. If you continue like this, I don’t think you have a future here</em>”. Alex does not observe; he doesn’t listen; he is not sincere nor interested in others. He assumes things about John rather than talking with him. How do you think John would have responded if Alex said something amongst the lines of:</p><blockquote>“It’s the fourth week in a row that you haven’t reached your target. Are you alright? Can I help?”</blockquote><p>This is how I believe a leader behaves. So the next time you start making assumptions about someone’s performance, please think twice and have a friendly conversation to figure out how someone is doing rather than assuming the worst.</p><p><em>Big thanks for reading my first article on Medium. I’m relatively new to the whole article writing, so I’m definitely sure there is room for improvement. If you have any feedback, questions or like to see more articles in the future, connect and reach out on </em><a href="http://linkedin.com/in/philohermans"><em>LinkedIn</em></a><em>.</em></p><p><em>This article was originally published on </em><a href="https://philo.dev/"><em>philo.dev</em></a><em>. Head over there if you like this post and want to read others like it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14bf8fa22bbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>