Improved the auto-build for the Docker image
parent
c78e6b35a2
commit
3d20d18bd3
|
@ -0,0 +1,55 @@
|
||||||
|
name: Build Docker image
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 3 * * 0'
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
paths-ignore:
|
||||||
|
- '.github/workflows/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version_tag:
|
||||||
|
description: 'Format: v[version number]'
|
||||||
|
required: true
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# scheduled run + on push
|
||||||
|
- name: Schedule + push - get the latest version tag
|
||||||
|
if: github.event_name == 'schedule' || github.event_name == 'push'
|
||||||
|
id: previoustag
|
||||||
|
uses: WyriHaximus/github-action-get-previous-tag@v1
|
||||||
|
|
||||||
|
- name: Schedule + push - create version tag
|
||||||
|
if: github.event_name == 'schedule' || github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
TAG="rabobankcdc/dettect:${{ steps.previoustag.outputs.tag }}"
|
||||||
|
echo "version_tag=${TAG}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# manual run
|
||||||
|
- name: Manual - create version tag
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
run: echo "version_tag=rabobankcdc/dettect:${{ github.event.inputs.version_tag }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push Docker images
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: rabobankcdc/dettect:latest, ${{ env.version_tag }}
|
|
@ -1,43 +0,0 @@
|
||||||
name: Build Docker image - on release
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- created
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Prepare
|
|
||||||
id: prep
|
|
||||||
run: |
|
|
||||||
DOCKER_IMAGE=rabobankcdc/dettect
|
|
||||||
VERSION=edge
|
|
||||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
||||||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
|
||||||
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
|
||||||
VERSION=pr-${{ github.event.number }}
|
|
||||||
fi
|
|
||||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
||||||
echo ::set-output name=tags::${TAGS}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push Docker images
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
tags: rabobankcdc/dettect:latest, ${{ steps.prep.outputs.tags }}
|
|
|
@ -1,30 +0,0 @@
|
||||||
name: Build Docker image - manual
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
version_tag:
|
|
||||||
description: 'Format: v[version number]'
|
|
||||||
required: true
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push Docker images
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
tags: rabobankcdc/dettect:latest, rabobankcdc/dettect:${{ github.event.inputs.version_tag }}
|
|
|
@ -1,6 +1,5 @@
|
||||||
name: Refresh Editor ATT&CK data
|
name: Refresh Editor ATT&CK data
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 */12 * * *'
|
- cron: '0 */12 * * *'
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
name: Update Wiki Help texts
|
name: Update Wiki Help texts
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
|
@ -13,7 +12,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Checkout wiki code
|
- name: Checkout wiki code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
|
@ -26,47 +25,47 @@ jobs:
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
- name: Update Help-texts.md markdown file
|
- name: Update Help-texts.md markdown file
|
||||||
run: |
|
run: |
|
||||||
HELPFILE='wiki/Help-texts.md'
|
HELPFILE='wiki/Help-texts.md'
|
||||||
|
|
||||||
TXT1="Below you will find all the help texts present in \`dettect.py\`:\n- [Main](#main)\n- [Editor](#editor)\n- [Datasource](#datasource)\n- [Visibility](#visibility)\n- [Detection](#detection)\n- [Group](#group)\n- [Generic](#generic)\n\n### Main\n\`python dettect.py -h\`\n\n\`\`\`"
|
TXT1="Below you will find all the help texts present in \`dettect.py\`:\n- [Main](#main)\n- [Editor](#editor)\n- [Datasource](#datasource)\n- [Visibility](#visibility)\n- [Detection](#detection)\n- [Group](#group)\n- [Generic](#generic)\n\n### Main\n\`python dettect.py -h\`\n\n\`\`\`"
|
||||||
echo "${TXT1//'\n'/$'\n'}" > $HELPFILE
|
echo "${TXT1//'\n'/$'\n'}" > $HELPFILE
|
||||||
python dettect.py -h >> $HELPFILE
|
python dettect.py -h >> $HELPFILE
|
||||||
|
|
||||||
TXT2="\`\`\`\n\n### Editor\n\`python dettect.py editor -h\`\n\n\`\`\`"
|
TXT2="\`\`\`\n\n### Editor\n\`python dettect.py editor -h\`\n\n\`\`\`"
|
||||||
echo "${TXT2//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT2//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py editor -h >> $HELPFILE
|
python dettect.py editor -h >> $HELPFILE
|
||||||
|
|
||||||
TXT3="\`\`\`\n\n### Datasource\n\`python dettect.py datasource -h\`\n\n\`\`\`"
|
TXT3="\`\`\`\n\n### Datasource\n\`python dettect.py datasource -h\`\n\n\`\`\`"
|
||||||
echo "${TXT3//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT3//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py ds -h >> $HELPFILE
|
python dettect.py ds -h >> $HELPFILE
|
||||||
|
|
||||||
TXT4="\`\`\`\n\n### Visibility\n\`python dettect.py visibility -h\`\n\n\`\`\`"
|
TXT4="\`\`\`\n\n### Visibility\n\`python dettect.py visibility -h\`\n\n\`\`\`"
|
||||||
echo "${TXT4//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT4//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py v -h >> $HELPFILE
|
python dettect.py v -h >> $HELPFILE
|
||||||
|
|
||||||
TXT5="\`\`\`\n\n### Detection\n\`python dettect.py detection -h\`\n\n\`\`\`"
|
TXT5="\`\`\`\n\n### Detection\n\`python dettect.py detection -h\`\n\n\`\`\`"
|
||||||
echo "${TXT5//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT5//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py d -h >> $HELPFILE
|
python dettect.py d -h >> $HELPFILE
|
||||||
|
|
||||||
TXT6="\`\`\`\n\n### Group\n\`python dettect.py group -h\`\n\n\`\`\`"
|
TXT6="\`\`\`\n\n### Group\n\`python dettect.py group -h\`\n\n\`\`\`"
|
||||||
echo "${TXT6//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT6//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py g -h >> $HELPFILE
|
python dettect.py g -h >> $HELPFILE
|
||||||
|
|
||||||
TXT7="\`\`\`\n\n### Generic\n\`python dettect.py generic -h\`\n\n\`\`\`"
|
TXT7="\`\`\`\n\n### Generic\n\`python dettect.py generic -h\`\n\n\`\`\`"
|
||||||
echo "${TXT7//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT7//'\n'/$'\n'}" >> $HELPFILE
|
||||||
python dettect.py ge -h >> $HELPFILE
|
python dettect.py ge -h >> $HELPFILE
|
||||||
|
|
||||||
TXT8="\`\`\`"
|
TXT8="\`\`\`"
|
||||||
echo "${TXT8//'\n'/$'\n'}" >> $HELPFILE
|
echo "${TXT8//'\n'/$'\n'}" >> $HELPFILE
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
id: changes
|
id: changes
|
||||||
working-directory: ./wiki
|
working-directory: ./wiki
|
||||||
|
@ -74,7 +73,7 @@ jobs:
|
||||||
OUTPUT=`git status`
|
OUTPUT=`git status`
|
||||||
echo ::set-output name=GIT_STATUS::${OUTPUT}
|
echo ::set-output name=GIT_STATUS::${OUTPUT}
|
||||||
echo $OUTPUT
|
echo $OUTPUT
|
||||||
|
|
||||||
- name: Commit files (if applicable)
|
- name: Commit files (if applicable)
|
||||||
if: contains(steps.changes.outputs.GIT_STATUS, 'modified')
|
if: contains(steps.changes.outputs.GIT_STATUS, 'modified')
|
||||||
working-directory: ./wiki
|
working-directory: ./wiki
|
||||||
|
@ -83,7 +82,7 @@ jobs:
|
||||||
git config --local user.name "GitHub Action"
|
git config --local user.name "GitHub Action"
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "Update Wiki help texts"
|
git commit -m "Update Wiki help texts"
|
||||||
|
|
||||||
- name: Push changes (if applicable)
|
- name: Push changes (if applicable)
|
||||||
if: contains(steps.changes.outputs.GIT_STATUS, 'modified')
|
if: contains(steps.changes.outputs.GIT_STATUS, 'modified')
|
||||||
uses: ad-m/github-push-action@master
|
uses: ad-m/github-push-action@master
|
||||||
|
@ -91,4 +90,4 @@ jobs:
|
||||||
directory: wiki
|
directory: wiki
|
||||||
repository: ${{github.repository}}.wiki
|
repository: ${{github.repository}}.wiki
|
||||||
github_token: ${{ secrets.PERSONAL_TOKEN }}
|
github_token: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue