xref: /DragonOS/.github/workflows/publish-dragonos-docker-image.yml (revision fae6e9ade46a52976ad5d099643d51cc20876448)
1name: Publish Docker images
2
3on:
4  workflow_dispatch:
5  push:
6    paths:
7      - tools/BUILD_CONTAINER_VERSION
8    branches:
9      - master
10
11jobs:
12  docker:
13    runs-on: ubuntu-latest
14    steps:
15      - name: Set up Docker Buildx
16        uses: docker/setup-buildx-action@v2
17
18      - name: Login to Docker Hub
19        uses: docker/login-action@v2
20        with:
21          username: ${{ secrets.DOCKERHUB_USERNAME }}
22          password: ${{ secrets.DOCKERHUB_TOKEN }}
23
24      - uses: actions/checkout@v4
25
26      - name: Fetch versions in the repo
27        id: fetch-versions
28        run: |
29          BUILD_CONTAINER_VERSION=$(cat tools/BUILD_CONTAINER_VERSION)
30          echo "build_container_version=$BUILD_CONTAINER_VERSION" >> "$GITHUB_OUTPUT"
31
32      - name: Build and push docker image
33        uses: docker/build-push-action@v4
34        with:
35          context: "{{defaultContext}}:tools"
36          file: Dockerfile
37          platforms: linux/amd64
38          push: true
39          tags: dragonos/dragonos-dev:${{ steps.fetch-versions.outputs.build_container_version }}
40