Skip to content

Commit

Permalink
Added github workflow to master
Browse files Browse the repository at this point in the history
  • Loading branch information
ohnotnow committed Jan 27, 2021
1 parent 0eb8c60 commit d8caedf
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: build-images

on:
# push:
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: homestead
MYSQL_DATABASE: homestead
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push QA
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64 #,linux/arm/v7,linux/arm64
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
target: ci
build-args: |
PHP_VERSION=7.4
tags: |
uogsoe/${{ github.event.repository.name }}:qa-${{ github.sha }}
- name: Run tests
uses: addnab/docker-run-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
options: "--network host"
image: uogsoe/${{ github.event.repository.name }}:qa-${{ github.sha }}
run: rm -fv .env && cp -v .env.github .env && php artisan config:clear && CI=1 APP_ENV=testing ./vendor/bin/phpunit -c phpunit.github.xml
- name: Build and push prod
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64 #,linux/arm/v7,linux/arm64
push: true
target: prod
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
PHP_VERSION=7.4
tags: |
uogsoe/${{ github.event.repository.name }}:prod-${{ github.sha }}

0 comments on commit d8caedf

Please sign in to comment.