-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.03 KB
/
release.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
name: Release
'on':
pull_request:
push:
branches:
- main
schedule:
- cron: "0 7 * * 0"
env:
IMAGE_NAME: silk_analysis
jobs:
# Test the image builds and works correctly.
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install pytest-testinfra
- name: Build image.
run: docker build -t cmusei/${{ env.IMAGE_NAME }} .
- name: Run the built image.
run: docker run --name=${{ env.IMAGE_NAME }} -td cmusei/${{ env.IMAGE_NAME }}
- name: Test the built image.
run: py.test --hosts='docker://${{ env.IMAGE_NAME }}'
# If on main branch, build and release image.
release:
name: Release
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image.
uses: docker/build-push-action@v6
with:
context: ./
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
cmusei/${{ env.IMAGE_NAME }}:latest
cmusei/${{ env.IMAGE_NAME }}:3
cmusei/${{ env.IMAGE_NAME }}:3.23.1
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:latest
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:3
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:3.23.1