Skip to content

Commit

Permalink
Add GitHub action CI support for repositories hosted outside of VIP G…
Browse files Browse the repository at this point in the history
…itHub org (#235)
  • Loading branch information
kasparsd committed Jul 6, 2023
1 parent 820bb24 commit 29bab49
Show file tree
Hide file tree
Showing 10 changed files with 28,329 additions and 38,304 deletions.
3 changes: 2 additions & 1 deletion .distinclude
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List all files and directories to be deployed to VIP Go servers.
# List all files and directories to be deployed to VIP source repository.
# Use the rsync syntax https://linux.die.net/man/1/rsync

+ /client-mu-plugins/
Expand All @@ -15,3 +15,4 @@
- /*
- .gitignore
- /object-cache.php
- /client-mu-plugins/tests/
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Specify the issue number or Jira issue link: -->
Fixes #

## Tasks

- [x] One important thing done.
- [ ] Another left to do.

## Describe the Approach

- Use bullet points to describe the change.

- Describe why the particular approach was chosen.
39 changes: 39 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Publish Docker Images

on:
push:
paths:
- '.github/workflows/**'
- 'docker-compose.yml'
- 'local/docker/**'

jobs:

build-and-push-image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
run: docker-compose build

- name: Publish images
if: github.ref_name == 'master'
run: docker buildx bake --push --set '*.platform=linux/amd64,linux/arm64'
78 changes: 78 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test and deploy

on: push

jobs:
deploy:

name: Lint, Test and Deploy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
tools: composer:v2

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer packages
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Log in to the Docker container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull custom Docker images
run: docker-compose pull wordpress mkcert

- name: Install Node dependencies
run: npm install --ignore-scripts

- name: Install Composer dependencies
run: composer install

- name: Lint
run: npm run lint

- name: Setup tests
run: mkdir uploads

- name: Test
run: npm run test

- name: Setup SSH deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_SSH_KEY }}
known_hosts: github.com

- name: Setup Git credentials
run: |
git config --global user.name "XWP Deploy Bot"
git config --global user.email "technology@xwp.co"
- name: Deploy to develop
if: github.ref_name == 'develop'
run: npm run deploy-staging

- name: Deploy to production
if: github.ref_name == 'main'
run: npm run deploy-production
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Delete this file if using GitHub actions for CI.
dist: bionic

services:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:

# Generate SSL certs for the local development environment.
mkcert:
image: ghcr.io/xwp/vip-site-template--mkcert:1.0.0
build: ./local/docker/mkcert
volumes:
- cert_data:/root/.local/share/mkcert
Expand Down Expand Up @@ -93,6 +94,7 @@ services:
depends_on:
- db
build: ./local/docker/wordpress
image: ghcr.io/xwp/vip-site-template--wordpress:1.0.0
restart: always
volumes:
- ./local/public:/var/www/html
Expand Down
2 changes: 1 addition & 1 deletion local/docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -s https://getcomposer.org/installer | php --version=2.4.4 --filename=c
COPY config/php/* /usr/local/etc/php/conf.d/

# Setup xdebug and memcache.
RUN pecl install xdebug-3.1.5 memcache-8.0 \
RUN pecl install xdebug-3.1.5 memcache-8.2 \
&& docker-php-ext-enable xdebug memcache;

# Enable HTTPS endpoints for reverse proxy requests. Used for images.
Expand Down
Loading

0 comments on commit 29bab49

Please sign in to comment.