Upgrade Github Actions

This commit is contained in:
Bubka 2023-03-24 09:10:08 +01:00
parent 18e83e1f4a
commit 3239bc2231
6 changed files with 158 additions and 184 deletions

View File

@ -1,110 +0,0 @@
name: ci-docker-latest
on:
push:
branches:
- master
paths:
- .github/workflows/ci-docker-latest.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php
pull_request:
branches:
- master
paths:
- .github/workflows/ci-docker-latest.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php
jobs:
verify:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/checkout@v2.3.4
- name: Build test image
run: docker build --target test -t test-container .
- name: Run tests in test container
run: |
touch coverage.txt
docker run --rm \
test-container
- name: Build final image
run: docker build .
publish:
needs: [verify]
if: |
(github.event_name == 'push' && github.repository == 'Bubka/2FAuth') ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'Bubka/2FAuth' && github.actor != 'dependabot[bot]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set variables
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=version::latest
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
- name: Build and push to docker Hub
uses: docker/build-push-action@v2.6.1
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_vars.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.set_vars.outputs.version }}
push: true

View File

@ -1,10 +1,10 @@
name: ci-docker-dev
name: ci-docker-publish-dev
on:
push:
branches:
- dev
paths:
- .github/workflows/ci-docker-dev.yml
- .github/workflows/ci-docker-publish-dev.yml
- app/**
- bootstrap/**
- config/**
@ -27,7 +27,7 @@ on:
branches:
- dev
paths:
- .github/workflows/ci-docker-dev.yml
- .github/workflows/ci-docker-publish-dev.yml
- app/**
- bootstrap/**
- config/**
@ -54,15 +54,15 @@ jobs:
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'Bubka/2FAuth' && github.actor != 'dependabot[bot]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v1
- uses: docker/login-action@v2
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@ -72,19 +72,18 @@ jobs:
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=version::dev
echo ::set-output name=platforms::linux/amd64,linux/386
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/386" >> $GITHUB_OUTPUT
- name: Build and push to docker Hub
uses: docker/build-push-action@v2.6.1
uses: docker/build-push-action@v4
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_vars.outputs.version }}
VERSION=dev
tags: |
2fauth/2fauth:${{ steps.set_vars.outputs.version }}
2fauth/2fauth:dev
push: true

View File

@ -0,0 +1,76 @@
name: ci-docker-publish-release
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set tags
uses: actions/github-script@v6
id: set_tags
with:
# context.ref: For workflows triggered by release, this is the release tag created.
# A release tag is fully-formed as refs/tags/<tag_name> so we remove the 10 first
# characters to drop the 'refs/tags/' part.
script: |
const tag = context.ref.substring(10)
const version = tag.replace('v', '')
core.setOutput('version', version)
- name: Set variables
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7" >> $GITHUB_OUTPUT
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md
- name: Build and push to docker Hub with version as unique tag
uses: docker/build-push-action@v4
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_tags.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.set_tags.outputs.version }}
push: true
- name: Build and push to docker Hub with stable tag latest
# We do not want to publish a prerelease as the 'latest' image
if: ${{ github.event.release.prerelease == false }}
uses: docker/build-push-action@v4
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=latest
tags: |
2fauth/2fauth:latest
push: true

View File

@ -1,59 +0,0 @@
name: ci-docker-release
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.release.tag_name }}
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set version
uses: actions/github-script@v4
id: set_version
with:
script: |
const tag = context.ref.substring(10)
const version = tag.replace('v', '')
core.setOutput('version', version)
- name: Set variables
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v2.4.3
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md
- name: Build and push to docker Hub
uses: docker/build-push-action@v2.6.1
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_version.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.set_version.outputs.version }}
push: true

68
.github/workflows/ci-docker-test.yml vendored Normal file
View File

@ -0,0 +1,68 @@
name: ci-docker-test
on:
push:
branches:
- master
paths:
- .github/workflows/ci-docker-test.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php
pull_request:
branches:
- master
paths:
- .github/workflows/ci-docker-test.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php
jobs:
test:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/checkout@v3
- name: Build test image
run: docker build --target test -t test-container .
- name: Run tests in test container
run: |
touch coverage.txt
docker run --rm \
test-container
- name: Build final image
run: docker build .

View File

@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Pushes docker-compose
uses: dmnemec/copy_file_to_another_repo_action@main