Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
9e00e389
Unverified
Commit
9e00e389
authored
May 25, 2023
by
John Wang
Committed by
GitHub
May 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/add release action build (#204)
parent
02378337
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
143 deletions
+58
-143
build-api-image.sh
.github/workflows/build-api-image.sh
+0
-61
build-api-image.yml
.github/workflows/build-api-image.yml
+29
-11
build-web-image.sh
.github/workflows/build-web-image.sh
+0
-60
build-web-image.yml
.github/workflows/build-web-image.yml
+29
-11
No files found.
.github/workflows/build-api-image.sh
deleted
100644 → 0
View file @
02378337
#!/usr/bin/env bash
set
-eo
pipefail
SHA
=
$(
git rev-parse HEAD
)
REPO_NAME
=
langgenius/dify
API_REPO_NAME
=
"
${
REPO_NAME
}
-api"
if
[[
"
${
GITHUB_EVENT_NAME
}
"
==
"pull_request"
]]
;
then
REFSPEC
=
$(
echo
"
${
GITHUB_HEAD_REF
}
"
|
sed
's/[^a-zA-Z0-9]/-/g'
|
head
-c
40
)
PR_NUM
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/pull/::'
|
sed
's:/merge::'
)
LATEST_TAG
=
"pr-
${
PR_NUM
}
"
CACHE_FROM_TAG
=
"latest"
elif
[[
"
${
GITHUB_EVENT_NAME
}
"
==
"release"
]]
;
then
REFSPEC
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/tags/::'
|
head
-c
40
)
LATEST_TAG
=
"
${
REFSPEC
}
"
CACHE_FROM_TAG
=
"latest"
else
REFSPEC
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/heads/::'
|
sed
's/[^a-zA-Z0-9]/-/g'
|
head
-c
40
)
LATEST_TAG
=
"
${
REFSPEC
}
"
CACHE_FROM_TAG
=
"
${
REFSPEC
}
"
fi
if
[[
"
${
REFSPEC
}
"
==
"main"
]]
;
then
LATEST_TAG
=
"latest"
CACHE_FROM_TAG
=
"latest"
fi
echo
"Pulling cache image
${
API_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
if
docker pull
"
${
API_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
;
then
API_CACHE_FROM_SCRIPT
=
"--cache-from
${
API_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
else
echo
"WARNING: Failed to pull
${
API_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
, disable build image cache."
API_CACHE_FROM_SCRIPT
=
""
fi
cat
<<
EOF
Rolling with tags:
-
${
API_REPO_NAME
}
:
${
SHA
}
-
${
API_REPO_NAME
}
:
${
REFSPEC
}
-
${
API_REPO_NAME
}
:
${
LATEST_TAG
}
EOF
#
# Build image
#
cd
api
docker build
\
${
API_CACHE_FROM_SCRIPT
}
\
--build-arg
COMMIT_SHA
=
${
SHA
}
\
-t
"
${
API_REPO_NAME
}
:
${
SHA
}
"
\
-t
"
${
API_REPO_NAME
}
:
${
REFSPEC
}
"
\
-t
"
${
API_REPO_NAME
}
:
${
LATEST_TAG
}
"
\
--label
"sha=
${
SHA
}
"
\
--label
"built_at=
$(
date
)
"
\
--label
"build_actor=
${
GITHUB_ACTOR
}
"
\
.
# push
docker push
--all-tags
"
${
API_REPO_NAME
}
"
.github/workflows/build-api-image.yml
View file @
9e00e389
...
...
@@ -5,16 +5,19 @@ on:
branches
:
-
'
main'
-
'
deploy/dev'
release
:
types
:
[
published
]
jobs
:
build-and-push
:
runs-on
:
ubuntu-latest
if
:
github.event.pull_request.draft ==
false
steps
:
-
name
:
"
Checkout
${{
github.ref
}}
(
${{
github.sha
}}
)"
uses
:
actions/checkout@v2
with
:
persist-credentials
:
false
-
name
:
Set up QEMU
uses
:
docker/setup-qemu-action@v2
-
name
:
Set up Docker Buildx
uses
:
docker/setup-buildx-action@v2
-
name
:
Login to Docker Hub
uses
:
docker/login-action@v2
...
...
@@ -22,13 +25,28 @@ jobs:
username
:
${{ secrets.DOCKERHUB_USER }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
-
name
:
Build and push Docker image
shell
:
bash
env
:
DOCKERHUB_USER
:
${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN
:
${{ secrets.DOCKERHUB_TOKEN }}
run
:
|
/bin/bash .github/workflows/build-api-image.sh
-
name
:
Extract metadata (tags, labels) for Docker
id
:
meta
uses
:
docker/metadata-action@v4
with
:
images
:
langgenius/dify-api
tags
:
|
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name
:
Build and push
uses
:
docker/build-push-action@v4
with
:
context
:
"
{{defaultContext}}:api"
platforms
:
linux/amd64,linux/arm64
build-args
:
|
COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push
:
true
tags
:
${{ steps.meta.outputs.tags }}
labels
:
${{ steps.meta.outputs.labels }}
-
name
:
Deploy to server
if
:
github.ref == 'refs/heads/deploy/dev'
...
...
.github/workflows/build-web-image.sh
deleted
100644 → 0
View file @
02378337
#!/usr/bin/env bash
set
-eo
pipefail
SHA
=
$(
git rev-parse HEAD
)
REPO_NAME
=
langgenius/dify
WEB_REPO_NAME
=
"
${
REPO_NAME
}
-web"
if
[[
"
${
GITHUB_EVENT_NAME
}
"
==
"pull_request"
]]
;
then
REFSPEC
=
$(
echo
"
${
GITHUB_HEAD_REF
}
"
|
sed
's/[^a-zA-Z0-9]/-/g'
|
head
-c
40
)
PR_NUM
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/pull/::'
|
sed
's:/merge::'
)
LATEST_TAG
=
"pr-
${
PR_NUM
}
"
CACHE_FROM_TAG
=
"latest"
elif
[[
"
${
GITHUB_EVENT_NAME
}
"
==
"release"
]]
;
then
REFSPEC
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/tags/::'
|
head
-c
40
)
LATEST_TAG
=
"
${
REFSPEC
}
"
CACHE_FROM_TAG
=
"latest"
else
REFSPEC
=
$(
echo
"
${
GITHUB_REF
}
"
|
sed
's:refs/heads/::'
|
sed
's/[^a-zA-Z0-9]/-/g'
|
head
-c
40
)
LATEST_TAG
=
"
${
REFSPEC
}
"
CACHE_FROM_TAG
=
"
${
REFSPEC
}
"
fi
if
[[
"
${
REFSPEC
}
"
==
"main"
]]
;
then
LATEST_TAG
=
"latest"
CACHE_FROM_TAG
=
"latest"
fi
echo
"Pulling cache image
${
WEB_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
if
docker pull
"
${
WEB_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
;
then
WEB_CACHE_FROM_SCRIPT
=
"--cache-from
${
WEB_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
"
else
echo
"WARNING: Failed to pull
${
WEB_REPO_NAME
}
:
${
CACHE_FROM_TAG
}
, disable build image cache."
WEB_CACHE_FROM_SCRIPT
=
""
fi
cat
<<
EOF
Rolling with tags:
-
${
WEB_REPO_NAME
}
:
${
SHA
}
-
${
WEB_REPO_NAME
}
:
${
REFSPEC
}
-
${
WEB_REPO_NAME
}
:
${
LATEST_TAG
}
EOF
#
# Build image
#
cd
web
docker build
\
${
WEB_CACHE_FROM_SCRIPT
}
\
--build-arg
COMMIT_SHA
=
${
SHA
}
\
-t
"
${
WEB_REPO_NAME
}
:
${
SHA
}
"
\
-t
"
${
WEB_REPO_NAME
}
:
${
REFSPEC
}
"
\
-t
"
${
WEB_REPO_NAME
}
:
${
LATEST_TAG
}
"
\
--label
"sha=
${
SHA
}
"
\
--label
"built_at=
$(
date
)
"
\
--label
"build_actor=
${
GITHUB_ACTOR
}
"
\
.
docker push
--all-tags
"
${
WEB_REPO_NAME
}
"
\ No newline at end of file
.github/workflows/build-web-image.yml
View file @
9e00e389
...
...
@@ -5,16 +5,19 @@ on:
branches
:
-
'
main'
-
'
deploy/dev'
release
:
types
:
[
published
]
jobs
:
build-and-push
:
runs-on
:
ubuntu-latest
if
:
github.event.pull_request.draft ==
false
steps
:
-
name
:
"
Checkout
${{
github.ref
}}
(
${{
github.sha
}}
)"
uses
:
actions/checkout@v2
with
:
persist-credentials
:
false
-
name
:
Set up QEMU
uses
:
docker/setup-qemu-action@v2
-
name
:
Set up Docker Buildx
uses
:
docker/setup-buildx-action@v2
-
name
:
Login to Docker Hub
uses
:
docker/login-action@v2
...
...
@@ -22,13 +25,28 @@ jobs:
username
:
${{ secrets.DOCKERHUB_USER }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
-
name
:
Build and push Docker image
shell
:
bash
env
:
DOCKERHUB_USER
:
${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN
:
${{ secrets.DOCKERHUB_TOKEN }}
run
:
|
/bin/bash .github/workflows/build-web-image.sh
-
name
:
Extract metadata (tags, labels) for Docker
id
:
meta
uses
:
docker/metadata-action@v4
with
:
images
:
langgenius/dify-web
tags
:
|
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name
:
Build and push
uses
:
docker/build-push-action@v4
with
:
context
:
"
{{defaultContext}}:web"
platforms
:
linux/amd64,linux/arm64
build-args
:
|
COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push
:
true
tags
:
${{ steps.meta.outputs.tags }}
labels
:
${{ steps.meta.outputs.labels }}
-
name
:
Deploy to server
if
:
github.ref == 'refs/heads/deploy/dev'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment