-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
89 additions
and
119 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 |
---|---|---|
@@ -1,68 +1,57 @@ | ||
name: build-dev | ||
|
||
env: | ||
REPO_NAME: ${{ github.event.repository.name }} | ||
BUILD_TAG: 'dev' | ||
|
||
on: | ||
push: | ||
branches: 'dev' | ||
tags: 'dev' | ||
|
||
|
||
jobs: | ||
dev: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag_name: ${{ steps.prepare.outputs.tag_name }} | ||
version: ${{ steps.prepare.outputs.version }} | ||
build_date: ${{ steps.prepare.outputs.build_date }} | ||
steps: | ||
- | ||
name: Prepare | ||
- name: Prepare | ||
id: prepare | ||
env: | ||
PROJECT_NAME: juke-restainer | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
run: | | ||
TAG=dev | ||
echo ::set-output name=tag_name::${TAG} | ||
echo ::set-output name=version::${TAG} | ||
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
echo ::set-output name=docker_platforms::linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 | ||
echo ::set-output name=docker_username::${DOCKER_USERNAME} | ||
echo ::set-output name=docker_image::${DOCKER_USERNAME}/${PROJECT_NAME} | ||
- | ||
name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Docker Buildx (no push) | ||
run: | | ||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \ | ||
--output "type=image,push=false" \ | ||
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \ | ||
--build-arg "VCS_REF=${GITHUB_SHA::8}" \ | ||
--build-arg "VERSION=${{ steps.prepare.outputs.version }}" \ | ||
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \ | ||
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \ | ||
--file Dockerfile . | ||
- | ||
name: Docker login and push | ||
if: success() | ||
env: | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin | ||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \ | ||
--output "type=image,push=true" \ | ||
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \ | ||
--build-arg "VCS_REF=${GITHUB_SHA::8}" \ | ||
--build-arg "VERSION=${{ steps.prepare.outputs.version }}" \ | ||
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \ | ||
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \ | ||
--file Dockerfile . | ||
- | ||
name: Docker Check Manifest | ||
if: always() | ||
run: | | ||
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} | ||
- | ||
name: Clear | ||
if: always() | ||
run: | | ||
rm -f ${HOME}/.docker/config.json | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
echo "tag_name=${TAG}" >> $GITHUB_OUTPUT | ||
echo "version=${TAG%-*}" >> $GITHUB_OUTPUT | ||
else | ||
echo "tag_name=snapshot" >> $GITHUB_OUTPUT | ||
echo "version=snapshot" >> $GITHUB_OUTPUT | ||
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | ||
fi | ||
dev: | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
steps: | ||
- run: 'echo Building ${{ env.REPO_NAME }} with tag=${{needs.prepare.outputs.tag_name}} version=${{needs.prepare.outputs.version}} Build Date=${{needs.prepare.outputs.build_date}}' | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.REPO_NAME }}:${{ env.BUILD_TAG }} |
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