-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (34 loc) · 1.48 KB
/
docker-image.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
name: Docker Image CI
on:
push:
branches:
- main
paths:
- Dockerfile
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
#For architecture emulation
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
#For multi-architecture image building
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build the specific stage of the multi-stage Dockerfile
- uses: actions/checkout@v3
- name: Set Docker repository name
id: set_docker_repo_name
run: echo "::set-output name=docker_repo_name::$(echo ${GITHUB_REPOSITORY#*/} | tr '[:upper:]' '[:lower:]')"
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:latest -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:$(date +"%Y%m%d%H%M%S") .devcontainer/ros2/.
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.set_docker_repo_name.outputs.docker_repo_name }}:$(date +"%Y%m%d%H%M%S")