Skip to content

Commit

Permalink
Add Github actions workflow
Browse files Browse the repository at this point in the history
Add Github actions workflow to build and push the base thanatos
container image to ghcr.io when a git tag is pushed
  • Loading branch information
MEhrn00 committed Dec 12, 2023
1 parent 047db4f commit c935ce9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and push the base container image

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_DESCRIPTION: "Base container image for the Thanatos Mythic C2 agent"
IMAGE_SOURCE: https://github.com/${{ github.repository }}
IMAGE_LICENSE: BSD-3-Clause

jobs:
verify-tag:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Lowercase the container image name
run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}

- name: Verify the Dockerfile references the correct image url
working-directory: Payload_Type/thanatos
run: |
grep "^FROM ${REGISTRY}/${IMAGE_NAME}:${GITHUB_REF_NAME}$" Dockerfile || (echo "Dockerfile reference does not match ${REGISTRY}/${IMAGE_NAME}:${GITHUB_REF_NAME}"; exit 1)
build-and-push-image:
runs-on: ubuntu-latest
needs: verify-tag

permissions:
contents: read
packages: write

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase the container image name
run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}

- name: Build and push the container image
uses: docker/build-push-action@v5
with:
context: Payload_Type/thanatos
file: Payload_Type/thanatos/.docker/Dockerfile
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
push: true
labels: |
org.opencontainers.image.source=${{ env.IMAGE_SOURCE }}
org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }}
org.opencontainers.image.licenses=${{ env.IMAGE_LICENSE }}
2 changes: 1 addition & 1 deletion Payload_Type/thanatos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Pull in the thanatos docker image
FROM docker.io/mehrn00/thanatos:v0.1.3
FROM ghcr.io/mythicagents/thanatos:v0.1.4

0 comments on commit c935ce9

Please sign in to comment.