only login to container registries if in main branch #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
schedule: | |
# build every first of the month | |
- cron: '0 0 1 * *' | |
push: | |
workflow_dispatch: | |
jobs: | |
grumphp: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.0 | |
- uses: actions/checkout@v2 | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.composer/cache/files | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- run: composer install --no-interaction --no-progress | |
- run: ./vendor/bin/grumphp run --ansi | |
- run: composer test | |
docker: | |
runs-on: ubuntu-latest | |
needs: [ grumphp ] | |
steps: | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- | |
name: Login to ghcr.io | |
uses: docker/login-action@v2 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: ghcr.io/kanti/local-https,kanti/local-https | |
build-args: | | |
STAGE=prod | |
RELEASE_TAG=${{ github.sha }} |