Skip to content

Commit

Permalink
Create docker-image.yml
Browse files Browse the repository at this point in the history
add docker build actions
  • Loading branch information
zibuyu28 authored Jun 27, 2024
1 parent de5e5da commit cb655c3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Prepare
id: prep
run: |
# Replace slashes with underscores and remove any characters that are not alphanumeric or underscores
REF_NAME=${{ github.ref_name }}
SAFE_REF_NAME=$(echo $REF_NAME | sed 's|/|_|g' | sed 's/[^a-zA-Z0-9_]//g')
echo "SAFE_REF_NAME=$SAFE_REF_NAME" >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Build and Push Docker image
run: |
DATE_TAG=$(date '+%Y%m%d%H%M%S')
IMAGE_TAG=${{ secrets.DOCKER_HUB_USERNAME }}/xlayer-nonde:${{ env.SAFE_REF_NAME }}-$DATE_TAG
docker build -t $IMAGE_TAG -f Dockerfile .
docker push $IMAGE_TAG

0 comments on commit cb655c3

Please sign in to comment.