-
Notifications
You must be signed in to change notification settings - Fork 5
55 lines (46 loc) · 1.47 KB
/
container.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
name: Tag, Build, and Push Docker Image with Github Workflow
#Set up tagging/building only on tag releases
on:
push:
tags: [ v* ]
paths-ignore:
- '**/README.md'
jobs:
build-container:
name: Build container
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Tag Output
id: vars
run: if [[ ${GITHUB_REF#refs/*/} == v* ]]; then echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT; else echo "tag=v" >> $GITHUB_OUTPUT; fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_ACCESS_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- uses: mad9000/actions-find-and-replace-string@2
id: findandreplace
with:
source: ${{ steps.vars.outputs.tag }}
find: 'v'
replace: 'version-'
- name: free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
yes | docker system prune
df -h
- name: Build, Tag, and Push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
file: ./Container/Dockerfile
push: true
tags: hmsccb/nhanes-workbench:latest, hmsccb/nhanes-workbench:${{ steps.findandreplace.outputs.value }}
cache-from: type=gha
cache-to: type=gha,mode=max