-
Notifications
You must be signed in to change notification settings - Fork 32
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
1 changed file
with
40 additions
and
18 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,28 +1,50 @@ | ||
name: build docker image and push to docker hub on release | ||
name: Build docker image and push to docker hub on release | ||
|
||
on: | ||
release: | ||
types: # This configuration does not affect the page_build event above | ||
- created | ||
|
||
env: | ||
PLATFORMS: "linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6" | ||
|
||
jobs: | ||
build: | ||
build_and_push: | ||
name: Build and push Docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: extract tag string | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- name: install buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
version: latest | ||
- name: login to docker hub | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
- name: build and push the image | ||
|
||
- name: Extract tag string | ||
id: git | ||
shell: bash | ||
run: | | ||
docker buildx build --push \ | ||
--tag shizunge/endlessh-go:latest \ | ||
--tag shizunge/endlessh-go:$RELEASE_VERSION \ | ||
--platform linux/amd64,linux/arm/v7,linux/arm64 . | ||
RELEASE_VERSION=${GITHUB_REF#refs/*/} | ||
echo "::set-output name=image_tag::${RELEASE_VERSION}" | ||
echo "Action image_tag=${RELEASE_VERSION}" | ||
- name: Login to docker hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Install buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }} | ||
uses: docker/[email protected] | ||
with: | ||
platforms: ${{ env.PLATFORMS }} | ||
push: true | ||
tags: | | ||
${{ github.repository }}:${{ steps.git.outputs.image_tag }} | ||
${{ github.repository }}:latest | ||
- name: Update dockerhub description | ||
uses: peter-evans/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
repository: ${{ github.repository }} | ||
short-description: ${{ github.event.repository.description }} |