Repository navigation
99 lines (87 loc) · 2.92 KB
/
Copy pathbuild_docker_rust_dev.yml
File metadata and controls
99 lines (87 loc) · 2.92 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Build Docker Image (Rust-dev)
on:
push:
branches:
- dev
paths-ignore:
- 'README.md'
- 'docker-compose.yml'
- 'docker-compose-warp.yml'
- 'docs/**'
- '.github/workflows/build_docker_main.yml'
- '.github/workflows/build_docker_dev.yml'
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Read the version from version.txt
id: get_version
run: |
version=$(cat version.txt)
echo "Current version: v$version-dev"
echo "::set-output name=version::v$version-dev"
- name: Commit and push version tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=${{ steps.get_version.outputs.version }}
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -f "$version-rust-dev"
git push -f https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git "$version-rust-dev"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set target images
id: set_images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
IMAGES="ghcr.io/${{ github.repository }}-rust"
if [ "$DOCKER_USERNAME" != "" ]; then
IMAGES="${IMAGES}
${DOCKER_USERNAME}/chat2api-rust"
fi
echo "images<<EOF" >> $GITHUB_OUTPUT
echo "$IMAGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
if: env.DOCKER_USERNAME != ''
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.set_images.outputs.images }}
tags: |
type=raw,value=latest-dev
type=raw,value=${{ steps.get_version.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: rust_docs/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max