|
1 | | -name: Build and Push Docker Image |
| 1 | +name: Rust |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - main |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
7 | 11 |
|
8 | 12 | jobs: |
9 | | - build-and-deploy: |
| 13 | + build: |
10 | 14 | runs-on: ubuntu-latest |
11 | 15 |
|
12 | 16 | steps: |
13 | | - - name: Checkout code |
14 | | - uses: actions/checkout@v2 |
15 | | - |
16 | | - - name: Set up Docker Buildx |
17 | | - uses: docker/setup-buildx-action@v2 |
18 | | - |
19 | | - - name: Cache Docker layers |
20 | | - uses: actions/cache@v2 |
21 | | - with: |
22 | | - path: /tmp/.buildx-cache |
23 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
24 | | - restore-keys: | |
25 | | - ${{ runner.os }}-buildx- |
26 | | -
|
27 | | - - name: Log in to GitHub Container Registry |
28 | | - uses: docker/login-action@v2 |
29 | | - with: |
30 | | - registry: ghcr.io |
31 | | - username: ${{ github.actor }} |
32 | | - password: ${{ secrets.GITHUB_TOKEN }} |
33 | | - |
34 | | - - name: Build and push Docker image |
35 | | - uses: docker/build-push-action@v3 |
36 | | - with: |
37 | | - context: . |
38 | | - push: true |
39 | | - tags: ghcr.io/${{ github.repository }}:latest |
40 | | - cache-from: type=local,src=/tmp/.buildx-cache |
41 | | - cache-to: type=local,dest=/tmp/.buildx-cache |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Build |
| 20 | + run: cargo build --release --verbose |
| 21 | + |
| 22 | + - name: Run tests |
| 23 | + run: cargo test --verbose |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v2 |
| 27 | + |
| 28 | + - name: Log in to Docker Hub |
| 29 | + uses: docker/login-action@v2 |
| 30 | + with: |
| 31 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 32 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 33 | + |
| 34 | + - name: Build and push Docker image |
| 35 | + uses: docker/build-push-action@v3 |
| 36 | + with: |
| 37 | + context: . |
| 38 | + push: true |
| 39 | + tags: ${{ secrets.DOCKER_USERNAME }}/splitr:latest |
| 40 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 41 | + cache-to: type=local,dest=/tmp/.buildx-cache |
0 commit comments