Refactor again (#11)

This commit is contained in:
Ryan (hackercat)
2021-05-28 11:31:42 +00:00
committed by GitHub
parent da6b7b185b
commit 6ffb01cfd3
21 changed files with 461 additions and 236 deletions
-4
View File
@@ -1,4 +0,0 @@
general:
vulnerabilities:
bestPracticeViolations:
- DKL-DI-0001 # * FATAL:Avoid sudo command
+5 -5
View File
@@ -1,7 +1,7 @@
version: 2
---
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: 'github-actions'
directory: '/'
- directory: /
package-ecosystem: github-actions
schedule:
interval: 'monthly'
interval: monthly
version: 2
+3 -1
View File
@@ -1,9 +1,11 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/hadolint/hadolint/master/contrib/hadolint.json
---
ignored:
- SC2086
- SC2059
- DL3004
- DL3002
- DL3008
- DL3016
- DL3018
- DL3003
trustedRegistries:
+108 -54
View File
@@ -1,27 +1,32 @@
name: Build alpine images
on:
schedule:
- cron: 0 12 */7 * *
push:
paths:
- '.github/workflows/build-alpine.yml'
- 'linux/alpine/act/**'
pull_request:
paths:
- '.github/workflows/build-alpine.yml'
- 'linux/alpine/act/**'
#schedule:
# - cron: 0 12 */7 * *
#push:
# paths:
# - '.github/workflows/build-alpine.yml'
# - 'linux/alpine/**'
# branches:
# - 'master'
#pull_request:
# paths:
# - '.github/workflows/build-alpine.yml'
# - 'linux/alpine/**'
workflow_dispatch:
env:
SLUG: ${{ github.repository_owner }}/alpine
IMAGE: alpine
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
jobs:
build:
name: Build
runs-on: ubuntu-latest
if: ${{ ( github.actor == github.repository_owner && github.event_name != 'pull_request' ) || ( github.actor != github.repository_owner ) }}
environment: Images
steps:
- name: Login to GitHub Container Registry
id: ghcr
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
registry: ghcr.io
@@ -30,7 +35,6 @@ jobs:
- name: Login to Quay
id: quay
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
registry: quay.io
@@ -39,15 +43,21 @@ jobs:
- name: Login to Docker Hub
id: dckr
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Print date in UTC format
id: print-date
run: echo "::set-output name=date::$(date +%Y%m%d)"
- name: Print tag
id: print-tag
run: |
if [ ${{ github.event_name }} == 'pull_request'}} && ${{ !env.ACT }} ]; then
echo "::set-output name=tag::PR-${{ github.event.number }}"
elif [ "${ACT}" == "true" ]; then
echo "::set-output name=tag::dev"
else
echo "::set-output name=tag::$(date +%Y%m%d)"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
@@ -57,56 +67,100 @@ jobs:
- uses: actions/checkout@v2
- name: Build and push ${{ github.repository_owner }}/alpine:act-${{ steps.print-date.outputs.date }}
id: act
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
GHCR_TAG: ghcr.io/${{ github.repository_owner }}/alpine:act
QUAY_TAG: quay.io/${{ github.repository_owner }}/alpine:act
DCKR_TAG: docker.io/${{ github.repository_owner }}/alpine:act
TAG: act-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
file: ./linux/alpine/act/base/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.GHCR_TAG }}
${{ env.GHCR_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.QUAY_TAG }}
${{ env.QUAY_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.DCKR_TAG }}
${{ env.DCKR_TAG }}-${{ steps.print-date.outputs.date }}
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
BASEIMAGE=node
TAG=lts-alpine3.13
DISTRIB_RELEASE=${{ steps.release.outputs.RELEASE }}
BUILD_TAG_VERSION=${{ steps.print-date.outputs.date }}
IMAGEOS=${{ env.IMAGE }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=act
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ github.repository_owner }}/alpine:runner-${{ steps.print-date.outputs.date }}
id: runner
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
env:
GHCR_TAG: ghcr.io/${{ github.repository_owner }}/alpine:runner
QUAY_TAG: quay.io/${{ github.repository_owner }}/alpine:runner
DCKR_TAG: docker.io/${{ github.repository_owner }}/alpine:runner
TAG: runner-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
file: ./linux/alpine/act/runner/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.GHCR_TAG }}
${{ env.GHCR_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.QUAY_TAG }}
${{ env.QUAY_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.DCKR_TAG }}
${{ env.DCKR_TAG }}-${{ steps.print-date.outputs.date }}
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
BASEIMAGE=catthehacker/alpine
TAG=act-${{ steps.print-date.outputs.date }}
BUILD_TAG_VERSION=${{ steps.print-date.outputs.date }}
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=runner
BUILD_REF=${{ github.sha }}
- uses: actions/setup-go@v1
with:
go-version: 1.16
- uses: actions/checkout@v2
with:
ref: cat/fix/change-image
repository: catthehacker/act-fork
path: act
- env:
ACT_TEST_IMAGE: ghcr.io/${{ env.SLUG }}:act-${{ steps.print-tag.outputs.tag }}
ACT_REPOSITORY: catthehacker/act-fork
ACT_OWNER: catthehacker
run: |
cd act/
go test ./...
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: act
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGEOS=${{ env.IMAGE }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=${{ env.TAG }}
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: runner
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=${{ env.TAG }}
BUILD_REF=${{ github.sha }}
+101 -48
View File
@@ -7,6 +7,8 @@ on:
paths:
- '.github/workflows/build-ubuntu.yml'
- 'linux/ubuntu/**'
branches:
- 'master'
pull_request:
paths:
- '.github/workflows/build-ubuntu.yml'
@@ -14,24 +16,23 @@ on:
workflow_dispatch:
env:
SLUG: ${{ github.repository_owner }}/ubuntu
IMAGE: ubuntu
PLATFORMS: linux/amd64,linux/arm64
NODE: '12'
jobs:
build:
name: Build
runs-on: ubuntu-latest
if: ${{ ( github.actor == github.repository_owner && github.event_name != 'pull_request' ) || ( github.actor != github.repository_owner ) }}
environment: Images
strategy:
fail-fast: true
max-parallel: 4
matrix:
BASEIMAGE: [ubuntu]
TAG: [latest, 20.04, 18.04, 16.04]
IMAGE_TYPE: [act]
steps:
- name: Login to GitHub Container Registry
id: ghcr
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
registry: ghcr.io
@@ -40,7 +41,6 @@ jobs:
- name: Login to Quay
id: quay
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
registry: quay.io
@@ -49,18 +49,25 @@ jobs:
- name: Login to Docker Hub
id: dckr
if: ${{ github.actor == github.repository_owner && !env.ACT }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Print date in UTC format
id: print-date
run: echo "::set-output name=date::$(date +%Y%m%d)"
- name: Print tag
id: print-tag
shell: sh
run: |
if ${{ github.event_name == 'pull_request' }} && ${{ !env.ACT }} ; then
echo "::set-output name=tag::PR-${{ github.event.number }}"
elif ${{ !env.ACT }} ; then
echo "::set-output name=tag::$(date +%Y%m%d)"
else
echo "::set-output name=tag::dev"
fi
- name: Set Ubuntu version to RELEASE
id: release
id: print-release
run: |
if [ "latest" = "${{ matrix.TAG }}" ]; then
echo "::set-output name=RELEASE::$(lsb_release -rs)"
@@ -76,56 +83,102 @@ jobs:
- uses: actions/checkout@v2
- name: Build and push ${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:act-${{ matrix.TAG }}-${{ steps.print-date.outputs.date }}
id: act
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
GHCR_TAG: ghcr.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:act-${{ matrix.TAG }}
QUAY_TAG: quay.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:act-${{ matrix.TAG }}
DCKR_TAG: docker.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:act-${{ matrix.TAG }}
TAG: act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
file: ./linux/${{ matrix.BASEIMAGE }}/act/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.GHCR_TAG }}
${{ env.GHCR_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.QUAY_TAG }}
${{ env.QUAY_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.DCKR_TAG }}
${{ env.DCKR_TAG }}-${{ steps.print-date.outputs.date }}
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
BASEIMAGE=buildpack-deps
TAG=${{ steps.release.outputs.RELEASE }}
IMAGEOS=${{ env.IMAGE }}
NODE_VERSION=${{ env.NODE }}
BUILD_TAG_VERSION=${{ steps.print-date.outputs.date }}
BUILD_TAG=act
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=act-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:runner-${{ matrix.TAG }}-${{ steps.print-date.outputs.date }}
id: runner
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
env:
GHCR_TAG: ghcr.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:runner-${{ matrix.TAG }}
QUAY_TAG: quay.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:runner-${{ matrix.TAG }}
DCKR_TAG: docker.io/${{ github.repository_owner }}/${{ matrix.BASEIMAGE }}:runner-${{ matrix.TAG }}
TAG: runner-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' && !env.ACT }}
file: ./linux/${{ matrix.BASEIMAGE }}/runner/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.GHCR_TAG }}
${{ env.GHCR_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.QUAY_TAG }}
${{ env.QUAY_TAG }}-${{ steps.print-date.outputs.date }}
${{ env.DCKR_TAG }}
${{ env.DCKR_TAG }}-${{ steps.print-date.outputs.date }}
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
BASEIMAGE=catthehacker/ubuntu
TAG=act-${{ matrix.TAG }}
BUILD_TAG_VERSION=${{ steps.print-date.outputs.date }}
BUILD_TAG=${{ matrix.IMAGE_TYPE }}
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=runner
BUILD_REF=${{ github.sha }}
- uses: actions/setup-go@v1
with:
go-version: 1.16
- uses: actions/checkout@v2
with:
ref: cat/fix/change-image
repository: catthehacker/act-fork
path: act
- env:
ACT_TEST_IMAGE: ghcr.io/${{ env.SLUG }}:act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
ACT_REPOSITORY: catthehacker/act-fork
ACT_OWNER: catthehacker
run: |
cd act/
go test ./...
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: act
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/act/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
NODE_VERSION=${{ env.NODE }}
IMAGEOS=${{ env.IMAGE }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=act-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}
- name: Build and push ${{ env.SLUG }}:${{ env.TAG }}
uses: docker/build-push-action@v2
env:
TAG: runner
with:
context: .
push: ${{ ( github.event_name != 'pull_request' && !env.ACT ) }}
file: ./linux/${{ env.IMAGE }}/runner/Dockerfile
platforms: ${{ env.PLATFORMS }}
tags: |
ghcr.io/${{ env.SLUG }}:${{ env.TAG }}
quay.io/${{ env.SLUG }}:${{ env.TAG }}
docker.io/${{ env.SLUG }}:${{ env.TAG }}
build-args: |
IMAGE=ghcr.io/${{ env.SLUG }}
IMAGEOS=${{ env.IMAGE }}
TAG=act-${{ matrix.TAG }}-${{ steps.print-tag.outputs.tag }}
BUILD_TAG_VERSION=${{ steps.print-tag.outputs.tag }}
BUILD_TAG=runner-${{ matrix.TAG }}
BUILD_REF=${{ github.sha }}
+3 -1
View File
@@ -2,6 +2,8 @@ name: Lint Code Base
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:
@@ -15,7 +17,7 @@ jobs:
with:
fetch-depth: 0
- name: Lint
uses: github/super-linter@v3
uses: nvuillam/mega-linter/flavors/documentation@v4
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name != 'pull_request' }}
DEFAULT_BRANCH: master