ci: use sccache for cargo & fix ci
This commit is contained in:
		
							parent
							
								
									ec365709b4
								
							
						
					
					
						commit
						e0991498fd
					
				
					 3 changed files with 24 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
when:
 | 
			
		||||
  - event: tag
 | 
			
		||||
    branch: main
 | 
			
		||||
    path: "agent/src/*"
 | 
			
		||||
 | 
			
		||||
matrix:
 | 
			
		||||
  BUILD_TARGET:
 | 
			
		||||
| 
						 | 
				
			
			@ -11,13 +10,19 @@ matrix:
 | 
			
		|||
steps:
 | 
			
		||||
  build:
 | 
			
		||||
    image: git.nikos.gg/prymn/rust/aarch64:latest
 | 
			
		||||
    environment:
 | 
			
		||||
      - RUSTC_WRAPPER=/usr/local/bin/sccache
 | 
			
		||||
      - SCCACHE_BUCKET=prymn-cargo-cache
 | 
			
		||||
      - SCCACHE_ENDPOINT=https://75178f9eca227dea51b3db4db2c15a5a.r2.cloudflarestorage.com
 | 
			
		||||
      - SCCACHE_REGION=auto
 | 
			
		||||
    secrets: [ aws_access_key_id, aws_secret_access_key ]
 | 
			
		||||
    commands:
 | 
			
		||||
      - protoc --version
 | 
			
		||||
      - cargo build --bin prymn_agent --release --target "${BUILD_TARGET}"
 | 
			
		||||
      - mkdir -p "dist/${BUILD_TARGET}"
 | 
			
		||||
      - cp "target/${BUILD_TARGET}/release/prymn_agent" "dist/${BUILD_TARGET}"
 | 
			
		||||
 | 
			
		||||
  release-binaries:
 | 
			
		||||
  upload:
 | 
			
		||||
    image: woodpeckerci/plugin-s3
 | 
			
		||||
    settings:
 | 
			
		||||
      bucket: prymn-static
 | 
			
		||||
| 
						 | 
				
			
			@ -27,4 +32,4 @@ steps:
 | 
			
		|||
      secret_key:
 | 
			
		||||
        from_secret: r2_secret_key
 | 
			
		||||
      source: dist/**/*
 | 
			
		||||
      target: /
 | 
			
		||||
      target: /agent
 | 
			
		||||
| 
						 | 
				
			
			@ -2,18 +2,24 @@ labels:
 | 
			
		|||
  platform: linux/arm64
 | 
			
		||||
 | 
			
		||||
when:
 | 
			
		||||
  - event: tag
 | 
			
		||||
  - event: push
 | 
			
		||||
    branch: main
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
  make-release:
 | 
			
		||||
    image: docker.io/hexpm/elixir:1.15.5-erlang-26.0.2-debian-bookworm-20230612
 | 
			
		||||
    image: git.nikos.gg/prymn/images/elixir:61de1c5f
 | 
			
		||||
    environment:
 | 
			
		||||
      - MIX_ENV=prod
 | 
			
		||||
    commands:
 | 
			
		||||
      - apt-get update -y && apt-get install -y build-essential
 | 
			
		||||
      - cd app
 | 
			
		||||
      - mix local.hex --force && mix local.rebar --force
 | 
			
		||||
      - cd app && mkdir -p _build
 | 
			
		||||
      ###  TODO: REMOVE WHEN TAILWIND FROM PHOENIX IS FIXED
 | 
			
		||||
      - curl -sfL https://github.com/tailwindlabs/tailwindcss/releases/download/v3.3.3/tailwindcss-linux-arm64 -o _build/tailwind-linux-arm64
 | 
			
		||||
      - curl -sfL https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.11.tgz -o /tmp/esbuild.tgz
 | 
			
		||||
      - tar zxf /tmp/esbuild.tgz -C /tmp
 | 
			
		||||
      - cp /tmp/package/bin/esbuild _build/esbuild-linux-arm64
 | 
			
		||||
      - chmod +x _build/esbuild-linux-arm64
 | 
			
		||||
      - chmod +x _build/tailwind-linux-arm64
 | 
			
		||||
      ###
 | 
			
		||||
      - mix deps.get --only prod
 | 
			
		||||
      - mix compile
 | 
			
		||||
      - mix assets.deploy
 | 
			
		||||
| 
						 | 
				
			
			@ -22,14 +28,11 @@ steps:
 | 
			
		|||
 | 
			
		||||
  deploy:
 | 
			
		||||
    image: alpine:latest
 | 
			
		||||
    environment:
 | 
			
		||||
      - REMOTE_SERVER="prymnci@${APP_SERVER_ADDRESS}"
 | 
			
		||||
      - DEPLOY_PATH="/srv/app"
 | 
			
		||||
    secrets: [ DEPLOY_KEY, APP_SERVER_ADDRESS ]
 | 
			
		||||
    commands:
 | 
			
		||||
      - apk add --no-cache openssh-client rsync
 | 
			
		||||
      - eval $(ssh-agent -s)
 | 
			
		||||
      - echo "${DEPLOY_KEY}" | ssh-add -
 | 
			
		||||
      - mkdir -p ~/.ssh && chmod 700 ~/.ssh
 | 
			
		||||
      - echo "${DEPLOY_KEY}" > ~/.ssh/known_hosts
 | 
			
		||||
      - cd app && rsync -avz --delete _build/prod/rel/prymn/ "${REMOTE_SERVER}:${DEPLOY_PATH}"
 | 
			
		||||
    secrets: [ DEPLOY_KEY ]
 | 
			
		||||
      - echo "$${DEPLOY_KEY}" | ssh-add -
 | 
			
		||||
      - mkdir -p ~/.ssh && chmod 700 /root/.ssh
 | 
			
		||||
      - ssh-keyscan -t rsa "$${APP_SERVER_ADDRESS}" > /root/.ssh/known_hosts
 | 
			
		||||
      - cd app && rsync -avz --delete _build/prod/rel/prymn/ "prymnci@$${APP_SERVER_ADDRESS}:/srv/app"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue