Tag Archives: php

Learning how to use Github Actions

I have spent the last few hours playing with Github actions. I had a need to scratch. Docker stopped the automated builds of my docker images for which I use within bitbucket pipelines.

Any time I used to commit to my git Bitbucket repo for the pipelines image a webhook would trigger this to build on Docker. Now however unless you fork out money to Docker this no longer works.

I could have worked out how to automate the process locally to build the image and push to docker hub but I wanted a more automated way. So I looked into Github Actions.

I also had another issue I wanted to solve. I need to maintain both a PHP 7.4 version for legacy apps and PHP 8.0 for newer apps. At the time I was only running the one version, PHP 7.4. After looking at what some of the other packages and services I use it seems most use a Docker file for the two versions. So I did that. Renamed my original and saved another with a couple of alterations.

I use Ansible to build the image anyway. So all I need to do is refactor a couple of variables to a new file and then call two different playbook. The two playbooks would then get called by the two different Dockerfiles.

Next step was to work our how Github Actions worked. After a bit of Googling and a few blog posts it seemed pretty straight forward. So a little tweaking and dummy commits I had two images being built and then pushed to Docker hub with different tags. This was already much better than I had in place already.

One last action I run from another server is to check for new Google Chrome releases and call a webhook to build the image again. This too took less than an hour to sort out and test.

Resources

Both the repository to build the image and the images are public. See the links below.

Github repository that builds the images https://github.com/lionslair/rzepecki-laravel-php

Docker Hub repo https://hub.docker.com/r/lionslair/rzepecki-laravel-php/tags?page=1&ordering=last_updated

Drupal Comment Field

I have been using this field in  a recent project needed to migrate data to it. No migrate handler existed so I created one. Probably the easiest five minutes I have used to program Drupal.

I have submitted it too https://www.drupal.org/node/2541912

But for those looking to migrate to this field use this code

 

<?php
class MigrateCommentFieldHandler extends MigrateFieldHandler {

  public function __construct() {
    $this->registerTypes(array('commentfield'));
  }

  public function prepare($entity, array $field_info, array $instance, array $values) {
    // Setup the Field API array for saving.
    $arguments = (isset($values['arguments'])) ? $values['arguments']: array();
    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
    $delta = 0;
    foreach ($values as $value) {
      $return[$language][$delta]['comment'] = $value['comment'];
      $return[$language][$delta]['created'] = $value['created'];
      $return[$language][$delta]['uid']     = $value['uid'];
      $delta++;
    }
    return isset($return) ? $return : NULL;
  }
}
?>

 

All the different Lorem Ipsum Generators

Lorem Ipsum is what programmers know as dummy or filler text when creating content for a web page or print media. It is used to populate the body of a node which forms part of some form of content such as a webpage, news article, blog etc.

A developers most hated job after fixing bugs is populating content. This can be automated via many different means how ever a lot of the time a field just needs to have content because it is not allowed to be blank. This enables developers to see how the output will get rendered for the general public and also may populate things such as a search index or a excerpt list of content.

The most commonly known Lorem Ipsum generator is http://www.lipsum.com/. an example of what we are talking about here can be found below.

 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pretium mollis ipsum eu molestie. Ut quis est in purus tristique ullamcorper. Aliquam eget felis mauris. Donec placerat justo ac faucibus scelerisque. Aliquam elementum pulvinar mi, ac interdum libero malesuada et. Fusce pellentesque lacus ut tellus tincidunt euismod. Suspendisse potenti. Integer id consequat ligula. Morbi vel urna a est varius dignissim. Aenean mattis venenatis mollis. Suspendisse mattis laoreet ante, sed sagittis quam dictum ut.

Below is a list of different Lorem Ipsum generators I have had bookmarked in the past and ones I have found writing this post.

Here are some I just haven’t used and probably would not

A good index of these sorts of sites is at http://chooseyouripsum.com/ If you have more of your own add them to the comments below.