-
Notifications
You must be signed in to change notification settings - Fork 8
37 lines (32 loc) · 1.17 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Build and Publish Docker Image
on:
push:
branches:
- develop
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
name: Publish Docker image to container registry
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Extract tag name
if: github.event_name == 'release'
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Validate tag
if: github.event_name == 'release'
run: |
if ! [[ "${{ env.TAG }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
echo "Invalid tag format. The tag must follow the semantic versioning format: X.Y.Z or X.Y.Z-prerelease"
exit 1
fi
- name: Build and publish Docker image
run: |
echo $GITHUB_TOKEN | docker login ghcr.io -u mitre-attack --password-stdin
docker build . --tag ghcr.io/mitre-attack/attack-workbench-taxii-server:${TAG:-latest}
docker push ghcr.io/mitre-attack/attack-workbench-taxii-server:${TAG:-latest}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ env.TAG }}