-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: CD for v3(main) | ||
|
||
on: | ||
push: | ||
branches: | ||
- v3 | ||
workflow_dispatch: | ||
|
||
env: | ||
DOCKER_TAG_API_URI: https://registry.hub.docker.com/v2/repositories/na2na/jetdisc/tags | ||
|
||
jobs: | ||
Prepare: | ||
name: Prepare | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag_exists: ${{ steps.check_docker_hub.outputs.tag_exists }} | ||
JETDISC_VERSION: ${{ steps.check_docker_hub.outputs.JETDISC_VERSION }} | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/[email protected] | ||
- name: Get current version | ||
id: get_version | ||
run: | | ||
echo "JETDISC_VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV | ||
- name: Check Docker Hub | ||
id: check_docker_hub | ||
run: | | ||
DOCKER_HUB_TAGS=$(curl -s ${{ env.DOCKER_TAG_API_URI }} | jq -r '.results[] | .name') | ||
if [ $(echo $DOCKER_HUB_TAGS | grep -c $JETDISC_VERSION) -eq 1 ]; then | ||
echo "Tag $JETDISC_VERSION already exists on Docker Hub." | ||
else | ||
echo "Tag $JETDISC_VERSION does not exist on Docker Hub." | ||
echo "tag_exists=false" >> $GITHUB_OUTPUT | ||
echo "JETDISC_VERSION=$JETDISC_VERSION" >> $GITHUB_OUTPUT | ||
fi | ||
Build-and-Push-to-Docker-Hub: | ||
needs: | ||
- Prepare | ||
if: ${{ needs.Prepare.outputs.tag_exists == 'false' }} | ||
with: | ||
JETDISC_VERSION: ${{ needs.Prepare.outputs.JETDISC_VERSION }} | ||
IMAGE_REPOSITORY: na2na | ||
IMAGE_NAME: jetdisc | ||
uses: ./.github/workflows/image-build-and-publish.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Publish Docker Image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
JETDISC_VERSION: | ||
required: true | ||
type: string | ||
IMAGE_REPOSITORY: | ||
required: true | ||
type: string | ||
IMAGE_NAME: | ||
required: true | ||
type: string | ||
secrets: {} | ||
|
||
jobs: | ||
Build-and-Push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Prepare for build | ||
id: prepare-for-build | ||
run: | | ||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
- name: Cache Docker Build Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: docker-build-cache-${{ github.ref }}-${{ github.sha }} | ||
restore-keys: | | ||
docker-build-cache-${{ github.ref }} | ||
docker-build-cache- | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver-opts: network=host | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build Docker Image | ||
run: | | ||
docker buildx bake \ | ||
-f 'infra/docker/image-bake.hcl' \ | ||
--builder="${{ steps.buildx.outputs.name }}" \ | ||
--set='web.tags=${{ inputs.IMAGE_REPOSITORY }}/${{ inputs.IMAGE_NAME }}:${{ inputs.JETDISC_VERSION }}' \ | ||
--set='web.tags=${{ inputs.IMAGE_REPOSITORY }}/${{ inputs.IMAGE_NAME }}:${{ steps.prepare-for-build.outputs.sha_short }}' \ | ||
--set='web.tags=${{ inputs.IMAGE_REPOSITORY }}/${{ inputs.IMAGE_NAME }}:release' \ | ||
--push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
group "default" { | ||
targets = ["app"] | ||
} | ||
|
||
target "app" { | ||
dockerfile = "Dockerfile" | ||
platforms = ["linux/amd64", "linux/arm64"] | ||
cache-to = ["type=local,dest=/tmp/.buildx-cache"] | ||
cache-from = ["type=local,src=/tmp/.buildx-cache"] | ||
} |