xref: /DragonOS/.github/workflows/publish-dragonos-docker-image.yml (revision 056c4aad81e21136912d20e6b0cb4c627f4250fa)
1415e46eaSLoGinname: Publish Docker images
2415e46eaSLoGin
3415e46eaSLoGinon:
4415e46eaSLoGin  workflow_dispatch:
5415e46eaSLoGin  push:
6415e46eaSLoGin    paths:
7415e46eaSLoGin      - tools/BUILD_CONTAINER_VERSION
8*056c4aadSLoGin    branches:
9*056c4aadSLoGin      - master
10415e46eaSLoGin
11415e46eaSLoGinjobs:
12415e46eaSLoGin  docker:
13415e46eaSLoGin    runs-on: ubuntu-latest
14415e46eaSLoGin    steps:
15415e46eaSLoGin      - name: Set up Docker Buildx
16415e46eaSLoGin        uses: docker/setup-buildx-action@v2
17415e46eaSLoGin
18415e46eaSLoGin      - name: Login to Docker Hub
19415e46eaSLoGin        uses: docker/login-action@v2
20415e46eaSLoGin        with:
21415e46eaSLoGin          username: ${{ secrets.DOCKERHUB_USERNAME }}
22415e46eaSLoGin          password: ${{ secrets.DOCKERHUB_TOKEN }}
23415e46eaSLoGin
24415e46eaSLoGin      - uses: actions/checkout@v4
25415e46eaSLoGin
26415e46eaSLoGin      - name: Fetch versions in the repo
27415e46eaSLoGin        id: fetch-versions
28415e46eaSLoGin        run: |
29415e46eaSLoGin          BUILD_CONTAINER_VERSION=$(cat tools/BUILD_CONTAINER_VERSION)
30415e46eaSLoGin          echo "build_container_version=$BUILD_CONTAINER_VERSION" >> "$GITHUB_OUTPUT"
31415e46eaSLoGin
32415e46eaSLoGin      - name: Build and push docker image
33415e46eaSLoGin        uses: docker/build-push-action@v4
34415e46eaSLoGin        with:
35*056c4aadSLoGin          context: "{{defaultContext}}:tools"
36*056c4aadSLoGin          file: Dockerfile
37415e46eaSLoGin          platforms: linux/amd64
38415e46eaSLoGin          push: true
39415e46eaSLoGin          tags: dragonos/dragonos-dev:${{ steps.fetch-versions.outputs.build_container_version }}
40