Skip to content

feat: github ci

feat: github ci #17

Workflow file for this run

name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # pull代码
- name: Build src
run: |
cargo build --release --verbose
- name: Run tests
run: |
cargo test --verbose
- name: Docker login
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_DOMAIN }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ${{ secrets.REGISTRY_DOMAIN }}/a2cd/rs-hello-world:latest
- name: Build and push image
env:
REGISTRY: ${{ secrets.REGISTRY_DOMAIN }}
NAMESPACE: a2cd
IMAGE_NAME: rs-hello-world
IMAGE_TAG: 20240110
IMAGE_TAG1: $(date "+%Y%m%d")
run: |
echo "当前路径:"
pwd
echo "文件:"
ls -l
echo $IMAGE_TAG1
docker build -t $REGISTRY/$NAMESPACE/$IMAGE_NAME:latest .
docker tag $REGISTRY/$NAMESPACE/$IMAGE_NAME:latest $REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_TAG
docker push $REGISTRY/$NAMESPACE/$IMAGE_NAME:latest
docker push $REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_TAG