-
Notifications
You must be signed in to change notification settings - Fork 18
60 lines (52 loc) · 1.97 KB
/
deploy-docker-image-main.yml
File metadata and controls
60 lines (52 loc) · 1.97 KB
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
name: Deploy - Docker Image Latest (main)
on:
workflow_dispatch:
## TODO: Implement the auto push later, manual release latest image for now
# push:
# branches: main
# paths:
# - 'Dockerfile'
# - 'scripts/*'
# - '.github/workflows/*'
jobs:
buildandpush:
runs-on: ubuntu-latest
# Docs: https://docs.github.com/en/actions/deployment/about-deployments/deploying-with-github-actions
environment: dockerhub
steps:
- name: Check out the repo
uses: actions/checkout@v5
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA"
- name: Verify tool versions
run: |
cd scripts
chmod +x check_version_in_toolkit.sh
./check_version_in_toolkit.sh "devops-toolkit-merge:$GITHUB_SHA" "../toolkit_info.json"
- name: Running Sample Tool Code
run: |
echo "Run sample tool code inside toolkit"
docker run --rm devops-toolkit-merge:$GITHUB_SHA samples/run_sample.sh
- name: Push Docker Image
run: |
SHA7=${GITHUB_SHA::7}
docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-$SHA7"
docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:latest"
docker images
echo "Push image with SHA"
docker push "tungbq/devops-toolkit:main-$SHA7"
echo "Push latest image"
docker push "tungbq/devops-toolkit:latest"
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tungbq/devops-toolkit
enable-url-completion: true