4.0.2 #107
Workflow file for this run
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: Publish Docker | |
on: | |
release: | |
types: [published] | |
branches: | |
- 'master' | |
workflow_dispatch: | |
env: | |
REPO: hlf01/telegram-onedrive | |
NAME: L-ING | |
EMAIL: [email protected] | |
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | |
TAG_NAME: ${{ github.event_name == 'workflow_dispatch' && 'dev' || github.event.release.name }} | |
RELEASE_VERSION: ${{ github.event.release.name }} | |
permissions: | |
contents: read | |
run-name: ${{ github.event_name == 'workflow_dispatch' && 'build dev' || github.event.release.name }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'hlf20010508' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
- name: Update Version | |
run: | | |
PROJECT_NAME=$(grep '^name = ' Cargo.toml | awk -F'"' '{print $2}') | |
sed -i "/^name = \"$PROJECT_NAME\"$/{N; s/version = \".*\"/version = \"$RELEASE_VERSION\"/}" Cargo.toml | |
sed -i "/^name = \"$PROJECT_NAME\"$/{N; s/version = \".*\"/version = \"$RELEASE_VERSION\"/}" Cargo.lock | |
if: github.event_name == 'release' && github.event.action == 'published' | |
- name: Commit and Push | |
run: | | |
git config --global user.name $NAME | |
git config --global user.email $EMAIL | |
git add -A | |
if git diff-index --quiet HEAD --; then | |
echo "Bypass commit." | |
else | |
git commit -m "chore: update version to $RELEASE_VERSION" | |
git tag -f $RELEASE_VERSION | |
git push origin HEAD:master | |
git push origin HEAD:master --tags -f | |
fi | |
if: github.event_name == 'release' && github.event.action == 'published' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push image | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.REPO }}:${{ env.RELEASE_VERSION }},${{ env.REPO }}:latest,${{ env.REPO }}:dev | |
if: github.event_name == 'release' && github.event.action == 'published' | |
- name: Build and push image dev | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.REPO }}:dev | |
if: github.event_name == 'workflow_dispatch' | |
- name: Send Notification | |
run: | | |
curl -X POST -d "title=Github Actions Notification&body=$GITHUB_REPOSITORY@$TAG_NAME build completed." ${{ secrets.WEBHOOK_URL }} |