mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Merge pull request #129 from shekhirin/fix-docker-commit-sha
fix(ci, http): commit_sha and commit_date in docker builds
This commit is contained in:
commit
6e1ddfea5a
6
.github/workflows/publish_to_docker.yml
vendored
6
.github/workflows/publish_to_docker.yml
vendored
@ -11,10 +11,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set COMMIT_DATE env variable
|
||||||
|
run: |
|
||||||
|
echo "COMMIT_DATE=$( git log --pretty=format:'%ad' -n1 --date=short )" >> $GITHUB_ENV
|
||||||
- name: Publish to Registry
|
- name: Publish to Registry
|
||||||
uses: elgohr/Publish-Docker-Github-Action@master
|
uses: elgohr/Publish-Docker-Github-Action@master
|
||||||
|
env:
|
||||||
|
COMMIT_SHA: ${{ github.sha }}
|
||||||
with:
|
with:
|
||||||
name: getmeili/meilisearch
|
name: getmeili/meilisearch
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
tag_names: true
|
tag_names: true
|
||||||
|
buildargs: COMMIT_SHA,COMMIT_DATE
|
||||||
|
@ -25,6 +25,11 @@ RUN $HOME/.cargo/bin/cargo build --release
|
|||||||
# Cleanup dummy main.rs files
|
# Cleanup dummy main.rs files
|
||||||
RUN find . -path "*/src/main.rs" -delete
|
RUN find . -path "*/src/main.rs" -delete
|
||||||
|
|
||||||
|
ARG COMMIT_SHA
|
||||||
|
ARG COMMIT_DATE
|
||||||
|
ENV COMMIT_SHA=${COMMIT_SHA}
|
||||||
|
ENV COMMIT_DATE=${COMMIT_DATE}
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN $HOME/.cargo/bin/cargo build --release
|
RUN $HOME/.cargo/bin/cargo build --release
|
||||||
|
|
||||||
|
@ -56,9 +56,18 @@ struct VersionResponse {
|
|||||||
|
|
||||||
#[get("/version", wrap = "Authentication::Private")]
|
#[get("/version", wrap = "Authentication::Private")]
|
||||||
async fn get_version() -> HttpResponse {
|
async fn get_version() -> HttpResponse {
|
||||||
HttpResponse::Ok().json(VersionResponse {
|
let commit_sha = match option_env!("COMMIT_SHA") {
|
||||||
commit_sha: env!("VERGEN_SHA").to_string(),
|
Some("") | None => env!("VERGEN_SHA"),
|
||||||
build_date: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
|
Some(commit_sha) => commit_sha
|
||||||
|
};
|
||||||
|
let commit_date = match option_env!("COMMIT_DATE") {
|
||||||
|
Some("") | None => env!("VERGEN_COMMIT_DATE"),
|
||||||
|
Some(commit_date) => commit_date
|
||||||
|
};
|
||||||
|
|
||||||
|
HttpResponse::Ok().json(VersionResponse {
|
||||||
|
commit_sha: commit_sha.to_string(),
|
||||||
|
build_date: commit_date.to_string(),
|
||||||
pkg_version: env!("CARGO_PKG_VERSION").to_string(),
|
pkg_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user