Skip to content

Replace Travis with GitHub Actions #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Build and Push Docker images to Docker Hub

on:
push:
branches: [ '**' ]
tags: [ '*' ]

schedule:
- cron: '0 0 * * *'

pull_request:
branches: [ master ]

jobs:
lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Lint
run: make lint

build-1:
name: PCF1

needs: lint

runs-on: ubuntu-latest

strategy:
matrix:
PHP: [5.6, '7.0', 7.1]
PCF: [1]

steps:
- uses: actions/checkout@v2
- id: branch
run: echo ::set-output name=result::${GITHUB_REF#refs/heads/}
- uses: actions/github-script@v3
id: tag
with:
script: |
const ref = process.env.GITHUB_REF
if (!ref.startsWith("refs/tags/")) {
return ''
}
const tag = ref.replace(/^refs\/tags\//, "")
return tag
result-encoding: string
- name: Build on PHP ${{ matrix.PHP }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make build PCF=${PCF} PHP=${PHP}
- name: Test
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make test PCF=${PCF} PHP=${PHP}
- name: Push Docker image to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
TAG: ${{ steps.tag.outputs.result }}
BRANCH: ${{ steps.branch.outputs.result }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: bash ./push.sh
pcf2:
name: PCF2
needs: lint
continue-on-error: true

runs-on: ubuntu-latest

strategy:
matrix:
PHP: [5.6, '7.0', 7.1, 7.2, 7.3, 7.4, latest]
PCF: [2]

steps:
- uses: actions/checkout@v2
- id: branch
run: echo ::set-output name=result::${GITHUB_REF#refs/heads/}
- uses: actions/github-script@v3
id: tag
with:
script: |
const ref = process.env.GITHUB_REF
if (!ref.startsWith("refs/tags/")) {
return ''
}
const tag = ref.replace(/^refs\/tags\//, "")
return tag
result-encoding: string
- name: Build on PHP ${{ matrix.PHP }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make build PCF=${PCF} PHP=${PHP}
- name: Test
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make test PCF=${PCF} PHP=${PHP}
- name: Push Docker image to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
TAG: ${{ steps.tag.outputs.result }}
BRANCH: ${{ steps.branch.outputs.result }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: bash ./push.sh

build-pcf-latest:
name: PCF Latest
needs: lint
continue-on-error: true

runs-on: ubuntu-latest

strategy:
matrix:
PHP: [5.6, '7.0', 7.1, 7.2, 7.3, 7.4, latest]
PCF: [latest]

steps:
- uses: actions/checkout@v2
- id: branch
run: echo ::set-output name=result::${GITHUB_REF#refs/heads/}
- uses: actions/github-script@v3
id: tag
with:
script: |
const ref = process.env.GITHUB_REF
if (!ref.startsWith("refs/tags/")) {
return ''
}
const tag = ref.replace(/^refs\/tags\//, "")
return tag
result-encoding: string
- name: Build on PHP ${{ matrix.PHP }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make build PCF=${PCF} PHP=${PHP}
- name: Test
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
run: make test PCF=${PCF} PHP=${PHP}
- name: Push Docker image to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
env:
PHP: ${{ matrix.PHP }}
PCF: ${{ matrix.PCF }}
TAG: ${{ steps.tag.outputs.result }}
BRANCH: ${{ steps.branch.outputs.result }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: bash ./push.sh
111 changes: 0 additions & 111 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
endif
else
ifeq ($(PHP),latest)
docker build --build-arg PHP=7-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
docker build --build-arg PHP=8-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
else
docker build --build-arg PHP=$(PHP)-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
endif
Expand All @@ -41,7 +41,7 @@ else
endif
else
ifeq ($(PHP),latest)
docker build --no-cache --build-arg PHP=7-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
docker build --no-cache --build-arg PHP=8-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
else
docker build --no-cache --build-arg PHP=$(PHP)-cli-alpine --build-arg PCF=$(PCF) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
endif
Expand Down
36 changes: 36 additions & 0 deletions push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

make login USER="${DOCKER_USERNAME}" PASS="${DOCKER_PASSWORD}"
if [ -n "${TAG}" ]; then
if [ "${PCF}" == "latest" ] && [ "${PHP}" == "latest" ]; then
make push TAG="latest-${TAG}"
else
if [ "${PHP}" == "latest" ]; then
make push TAG="${PCF}-${TAG}"
else
make push TAG="${PCF}-php${PHP}-${TAG}"
fi
fi
elif [ "${BRANCH}" == "master" ]; then
if [ "${PCF}" == "latest" ] && [ "${PHP}" == "latest" ]; then
make push TAG=latest
else
if [ "${PHP}" == "latest" ]; then
make push TAG=${PCF}
else
make push TAG=${PCF}-php${PHP}
fi
fi
elif [[ ${BRANCH} =~ ^(release-[.0-9]+)$ ]]; then
if [ "${PCF}" == "latest" ] && [ "${PHP}" == "latest" ]; then
make push TAG="latest-${BRANCH}"
else
if [ "${PHP}" == "latest" ]; then
make push TAG="${PCF}-${BRANCH}"
else
make push TAG="${PCF}-php${PHP}-${BRANCH}"
fi
fi
else
echo "Skipping branch ${BRANCH}"
fi