Skip to content

Merge pull request #78 from katmastt/main #31

Merge pull request #78 from katmastt/main

Merge pull request #78 from katmastt/main #31

name: Build
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Test build
run: docker-compose up -d
- name: Sleep
shell: bash
run: sleep 30;
- name: Test endpoint with output
shell: bash
run: curl --write-out '%{http_code}' --output /dev/null --silent localhost:8080/index.php?r=site/health
- name: Test endpoint
shell: bash
run: bash test-call.bash
- name: End test
run: docker-compose down
build:
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d%s')"
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ secrets.DOCKER_REGISTRY }}/clima:latest, ${{ secrets.DOCKER_REGISTRY }}/clima:${{ steps.date.outputs.date }}