Skip to content

Commit 6df26c3

Browse files
committed
fix: upload artifact github action
1 parent 6f96435 commit 6df26c3

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,62 +59,67 @@ jobs:
5959
release-github-artifact:
6060
name: Release Packaging
6161
env:
62-
PROJECT_NAME_UNDERSCORE: rust-api-server
62+
PROJECT_NAME_UNDERSCORE: rust-server
6363
runs-on: ubuntu-latest
6464
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
6565
needs: [cargo-check, fmt-check, test-and-coverage]
6666
steps:
6767
- name: Check out from Git
6868
uses: actions/checkout@v4
69+
6970
- name: Grant permission to run command
7071
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
72+
7173
- name: Check if Git tag exists
7274
run: echo "::set-env name=HEAD_TAG::$(git tag --points-at HEAD)"
75+
7376
- name: Skip if Git tag does not exist
7477
if: steps.check-tag.outputs.HEAD_TAG == ''
7578
run: exit 0 # Exit with success, effectively skipping subsequent steps
7679

77-
- uses: actions/checkout@v4
7880
- uses: actions-rs/toolchain@v1
7981
with:
8082
profile: minimal
8183
toolchain: stable
8284
override: true
85+
8386
- name: Release Build
84-
run: cargo build --release
87+
run: cargo build --release --bin cli
88+
8589
- name: "Upload Artifact"
86-
uses: actions/upload-artifact@v2
90+
uses: actions/upload-artifact@v4
8791
with:
8892
name: ${{ env.PROJECT_NAME_UNDERSCORE }}
89-
path: target/release/${{ env.PROJECT_NAME_UNDERSCORE }}
93+
path: target/release/cli
9094

9195
release-docker-image:
96+
env:
97+
DOCKER_HUB_REPOSITORY: thuan2172001/rust-server
9298
runs-on: ubuntu-latest
9399
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
94100
needs: [cargo-check, fmt-check, test-and-coverage]
95101
steps:
96102
- name: Check out from Git
97103
uses: actions/checkout@v4
104+
98105
- name: Grant permission to run command
99106
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
107+
100108
- name: Check if Git tag exists
101109
run: echo "::set-env name=HEAD_TAG::$(git tag --points-at HEAD)"
110+
102111
- name: Skip if Git tag does not exist
103112
if: steps.check-tag.outputs.HEAD_TAG == ''
104113
run: exit 0 # Exit with success, effectively skipping subsequent steps
105114

106-
- name: Checkout
107-
uses: actions/checkout@v4
108115
- name: Login to Docker Hub
109116
uses: docker/login-action@v3
110117
with:
111118
username: ${{ secrets.DOCKER_USERNAME }}
112119
password: ${{ secrets.DOCKERHUB_TOKEN }}
113-
- name: Set up Docker Buildx
114-
uses: docker/setup-buildx-action@v3
115-
- name: Build and push
116-
uses: docker/build-push-action@v5
117-
with:
118-
context: .
119-
target: prod
120-
load: true
120+
121+
- name: Build and push docker image
122+
run: |
123+
docker build . --tag ${{ env.DOCKER_HUB_REPOSITORY }}:latest
124+
docker push ${{ env.DOCKER_HUB_REPOSITORY }}:latest
125+

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010
Welcome to the Rust API Server! This server provides a simple REST interface for your applications. This README will
1111
guide you through setting up and running the server, as well as configuring its various options.
1212

13+
## Deploy
14+
**Automated Builds:**
15+
Builds are automatically generated for each commit to the repository in the `main` branch and are subsequently pushed to Docker Hub. Tags are applied using the commit SHA, branch name, and the latest tag if released on the main branch. You can find a list of available tags [here](https://hub.docker.com/r/thuan2172001/rust-server/tags).
16+
17+
**Release Binaries:**
18+
For every release, separate `cli` binaries are built. These binaries can be downloaded from [here](https://github.com/sonntuet1997/rust-web-api-microservice-template/releases) and are available for various operating systems and architectures. You are welcome to use the automated binaries or build your own.
19+
20+
**Contributions and PRs:**
21+
If you submit a pull request, please note that images are not built by default. A maintainer will need to retag them for the build process to take place.
22+
23+
### Docker
24+
1. Pull the docker image
25+
```commit to only the main branch
26+
docker pull thuan2172001/rust-server:latest
27+
```
28+
29+
2. Run the image
30+
```
31+
docker run -d -p 8000:8000 thuan2172001/rust-server:latest
32+
```
33+
1334
## How To Run
1435

1536
To get started, execute the following command in your terminal:

0 commit comments

Comments
 (0)