ci: build.
This commit is contained in:
		@@ -1,18 +1,70 @@
 | 
			
		||||
name: Gitea Actions Demo
 | 
			
		||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions
 | 
			
		||||
on: [push]
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
jobs:
 | 
			
		||||
  Explore-Gitea-Actions:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
 | 
			
		||||
      - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!"
 | 
			
		||||
      - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
 | 
			
		||||
 | 
			
		||||
      - name: Check out repository code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
      - run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
 | 
			
		||||
      - run: echo "The workflow is now ready to test your code on the runner."
 | 
			
		||||
      - name: List files in the repository
 | 
			
		||||
        run: |
 | 
			
		||||
          ls ${{ gitea.workspace }}
 | 
			
		||||
      - run: echo "This job's status is ${{ gitea.status }}."
 | 
			
		||||
 | 
			
		||||
      - name: Install Rust
 | 
			
		||||
        uses: actions-rs/toolchain@v1
 | 
			
		||||
        with:
 | 
			
		||||
          toolchain: stable
 | 
			
		||||
          override: true
 | 
			
		||||
 | 
			
		||||
      - id: commit
 | 
			
		||||
        uses: pr-mpt/actions-commit-hash@v2
 | 
			
		||||
 | 
			
		||||
      - name: Build
 | 
			
		||||
        run: cargo build --release
 | 
			
		||||
 | 
			
		||||
      - name: Cache Executable Binary
 | 
			
		||||
        uses: actions/cache@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: ./target/release/network-monitor
 | 
			
		||||
          key: ${{ runner.os }}-release-${{ steps.commit.outputs.short}}
 | 
			
		||||
 | 
			
		||||
  docker:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: build
 | 
			
		||||
 | 
			
		||||
    env:
 | 
			
		||||
      REGISTRY: gitea.ivanli.cc
 | 
			
		||||
      IMAGE_NAME: ${{ github.repository }}
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - id: restore-executable-binary
 | 
			
		||||
        name: Cache Executable Binaries
 | 
			
		||||
        uses: actions/cache@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: ./network-monitor
 | 
			
		||||
          key: ${{ runner.os }}-release-${{ steps.commit.outputs.short}}
 | 
			
		||||
      - if: ${{ steps.restore-executable-binary.outputs.cache-hit != 'true' }}
 | 
			
		||||
        name: List the state of node modules
 | 
			
		||||
        run: echo "missing program"
 | 
			
		||||
 | 
			
		||||
      - name: Log in to the Container registry
 | 
			
		||||
        uses: docker/login-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          registry: ${{ env.REGISTRY }}
 | 
			
		||||
          username: ${{ gitea.actor }}
 | 
			
		||||
          password: ${{ secrets.GITEA_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Extract metadata (tags, labels) for Docker
 | 
			
		||||
        id: meta
 | 
			
		||||
        uses: docker/metadata-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          registry: ${{ env.REGISTRY }}
 | 
			
		||||
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
 | 
			
		||||
 | 
			
		||||
      - name: Build and push Docker image
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: .
 | 
			
		||||
          push: true
 | 
			
		||||
          tags: ${{ steps.meta.outputs.tags }}
 | 
			
		||||
          labels: ${{ steps.meta.outputs.labels }}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
FROM alpine:latest
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
COPY ./target/release/network-monitor .
 | 
			
		||||
 | 
			
		||||
CMD ["./network-monitor"]
 | 
			
		||||
		Reference in New Issue
	
	Block a user