-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
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
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 }} |
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
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 |