Added backup script #155
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
name: Build Docker Image | |
on: | |
push: | |
jobs: | |
set_version: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get branch name | |
id: branch_name | |
run: | | |
GIT_BRANCH=`git symbolic-ref --short HEAD | sed "s/[^[:alnum:].]//g"` | |
echo "::set-output name=GIT_BRANCH::${GIT_BRANCH}" | |
- name: Get semantic version | |
uses: paulhatch/[email protected] | |
id: versioning | |
with: | |
tag_prefix: "v" | |
major_pattern: "[MAJOR]" | |
minor_pattern: "[MINOR]" | |
format: "${major}.${minor}.${patch}.dev${increment}" | |
bump_each_commit: false | |
outputs: | |
version: ${{ github.ref == 'refs/heads/master' && steps.versioning.outputs.version_tag || steps.versioning.outputs.version}} | |
buildx: | |
runs-on: ubuntu-latest | |
needs: [ set_version ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Inspect builder | |
run: | | |
echo "Name: ${{ steps.buildx.outputs.name }}" | |
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" | |
echo "Status: ${{ steps.buildx.outputs.status }}" | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" | |
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=toncenter/ton-http-api | |
if ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
then | |
DOCKER_PLATFORMS=linux/amd64,linux/arm64 | |
else | |
DOCKER_PLATFORMS=linux/amd64 | |
fi | |
VERSION=${{ needs.set_version.outputs.version }} | |
TAGS="-t ${DOCKER_IMAGE}:${VERSION} -t ${DOCKER_IMAGE}:latest" | |
echo ::set-output name=docker_image::${DOCKER_IMAGE} | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ | |
${TAGS} --file ton-http-api/.docker/Dockerfile ton-http-api \ | |
--cache-from=${DOCKER_IMAGE}:latest | |
echo "Pulling latest image for cache" | |
IFS=', ' read -r -a PLATFORMS <<< "${DOCKER_PLATFORMS}" | |
for platform in "${PLATFORMS[@]}" | |
do | |
echo "Pulling image for platform ${platform}" | |
docker pull --platform ${platform} ${{ steps.prepare.outputs.docker_image }}:latest || true | |
done | |
- name: Docker Buildx (build) | |
run: | | |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} | |
- name: Login to DockerHub | |
if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker Buildx (push) | |
if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' | |
run: | | |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} | |
- name: Inspect image | |
if: always() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' | |
run: | | |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} |