66 pull_request :
77 branches : [ main ]
88
9+ env :
10+ REGISTRY : ghcr.io
11+ IMAGE_NAME : ${{ github.repository }}
12+
913jobs :
1014 ci :
15+ name : Check code formatting and run clippy
1116 runs-on : ubuntu-latest
1217 steps :
1318 - name : Checkout code
14- uses : actions/checkout@v3
19+ uses : actions/checkout@v4
1520
1621 - name : Check code formatting
1722 run : cargo fmt -- --check
1823
1924 - name : Run cargo clippy
2025 run : cargo clippy -- -D warnings
2126
22- cd :
23- needs : ci
24- runs-on : [ropguy-pi]
25- env :
26- GITHUB_WORKSPACE : /home/ccerne/OpenGraal/preagonal-client
27+ build-and-push :
28+ name : Build and push Docker image
29+ runs-on : ubuntu-latest
30+ permissions :
31+ contents : read
32+ packages : write
33+ attestations : write
34+ id-token : write
2735 steps :
2836 - name : Checkout code
29- uses : actions/checkout@v3
30-
31- - name : Add Cargo to PATH
32- run : echo "$HOME/.cargo/bin" >> $GITHUB_PATH
33-
34- - name : Pull latest changes
35- run : cd $GITHUB_WORKSPACE && git pull origin main
36-
37- - name : Build service binary
38- run : cd $GITHUB_WORKSPACE && cargo build --release
39-
40- - name : Run service
41- run : sudo systemctl restart preagonal-client.service
37+ uses : actions/checkout@v4
38+
39+ - name : Log in to GitHub Container Registry
40+ uses : docker/login-action@v3
41+ with :
42+ registry : ${{ env.REGISTRY }}
43+ username : ${{ github.actor }}
44+ password : ${{ secrets.GITHUB_TOKEN }} # Or use a PAT stored in a secret
45+
46+ - name : Docker metadata
47+ users : docker/metadata-action@v5
48+ with :
49+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
51+ - name : Build and push Docker image
52+ uses : docker/build-push-action@v6
53+ with :
54+ context : .
55+ push : true
56+ tags : ${{ steps.meta.outputs.tags }}
57+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments