fix: better wf

This commit is contained in:
Ondrej Vlach 2023-12-10 17:05:13 +01:00
parent 9d7eaeeed3
commit 3e47f07885
Signed by: ovlach
GPG Key ID: 4FF1A23B4914DE70
2 changed files with 27 additions and 106 deletions

View File

@ -9,75 +9,42 @@ jobs:
name: tests name: tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: https://github.com/actions/checkout.git@v4 - uses: actions/rust-test@v1
- name: Hash of Cargo.lock
id: get-hash
run: echo "::set-output name=hash::$(md5sum Cargo.lock | awk '{ print $1; }')"
- uses: https://gitea.com/wolfogre/cache/restore@v3
id: cache
with: with:
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}" repository: ${{github.repository}}
path: | cargo_nan_secret: ${{secrets.deployment_package}}
.cache
target
restore-keys: ${{github.repository}}-cache-cargo-clippy-v4
- name: tests
uses: nanobyte-public/rust-action@v3
with:
args: |
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo clippy -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo clippy --tests -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo test
- uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
.cache
target
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}"
docker: docker:
name: docker name: docker
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: tests # require tests to pass before deploy runs outputs:
docker_image_version: ${{ steps.docker-image.outputs.image_version }}
container: container:
image: ovlach/docker-gitea:v0.0.2-alpha image: ovlach/docker-gitea:v0.0.2-alpha
steps: steps:
- uses: https://github.com/actions/checkout.git@v4 - uses: https://github.com/actions/checkout.git@v4
- name: Login to git.nanobyte.cz - uses: actions/docker-image@b6ee3d56e74e3786309bd59d201133060749954a
uses: https://github.com/docker/login-action@v3 id: docker-image
with: with:
username: ${{ secrets.DEPLOYMENT_PACKAGE }} deployment_login: ${{ secrets.DEPLOYMENT_PACKAGE }}
password: ${{ secrets.DEPLOYMENT_PACKAGE }} registry: 'git.nanobyte.cz'
registry: git.nanobyte.cz image_name: git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_pdf
- name: Get short hash from git repository aditional_args: --build-arg GITEA_TOKEN="${{secrets.DEPLOYMENT_PACKAGE}}"
id: git
run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
- name: Build and push docker
run: |
docker build . -t git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_pdf:${{steps.git.outputs.short_hash}} --build-arg GITEA_TOKEN="${{secrets.DEPLOYMENT_PACKAGE}}" && \
docker push git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_pdf:${{steps.git.outputs.short_hash}}
stage_deployment: stage_deployment:
name: stage-deployment name: stage-deployment
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [docker, tests] # require tests to pass before deploy runs needs: [docker, tests] # require tests to pass before deploy runs
if: ${{ success() }}
steps: steps:
- uses: https://github.com/actions/checkout.git@v4 - uses: https://github.com/actions/checkout.git@v4
- name: Get short hash from git repository - name: Get short hash from git repository
id: git id: git
run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)" run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
- uses: https://github.com/actions/checkout.git@v4 shell: sh
- uses: actions/argo-publish@74b6c94c4303d3f3786d76fb43a205589c08b2a7
with: with:
ssh-key: '${{ secrets.VLACH_XYZ_DEPLOY }}' argocd_app_repo: 'ovlach/vlach_xyz'
path: 'vlach_xyz_deploy' argocd_clone_ssh_key: ${{ secrets.VLACH_XYZ_DEPLOY }}
repository: 'ovlach/vlach_xyz' image: 'git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_pdf'
ref: 'master' image_name: 'pdf'
github-server-url: 'ssh://git.nanobyte.cz' image_version: '${{ steps.git.outputs.short_hash }}' # ${{ needs.docker.outputs.docker_image_version }} - not work due to https://gitea.com/gitea/act_runner/issues/358
ssh-known-hosts: 'git.nanobyte.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3senpFPTYk75y73d1xL4XEDBe5AcLJ+GLEA+XTMpMiLsociwUeJZCJZoRUsZBH1bSvlgT23wlHtGJvDARygCBX/rZKKIb0KdD5qYgbtCzdmyg1Aw6+RNbgsOZuuDqh1HCLftj6PZWKXfEyp1rLjVCJEBmK2+iC54VjGTrm/0D3Mi1Tzpbmz0U+SqiZpNmC4GJu3riyxcXBrySsEZjWFcrUGSfVW9/MzzNk6relemGrkvBFDh6+lcx5bvPi3wamm0dlS+ySB9GhkGMukjCHHGLleRRZB3hf8ClbiMrod0KXwG1RQzqBIn3or4AUrl2ExIeA+olBTGIooy1sf/s8qBSGytYwUR1wbkMa9SIPWxIyioQY2uPu8Jg2qUYyZCJLNMeCVne5QGfxcDPm468pkkKOHVDqsVmhzRvcLuadpLHffZRg9Ds8LWSpIZh/OSWUkeavP0kSEN+vC4j/pFepYId3GJrEv/FN8KvdxKndkH2WyK2JAMcbTQAq3LiUgApuSuY1717VYNEhkEJ7u4NNmZhkW7WpTU75TCwMqrR77/eHO3ou5U7LEAKE4ujXrRX6HDgiRpg4psnI48hoJ/K50DYCL9CUAYcXLXjWhfmYUaN/1FYWS6cNpaTcwqOsdpYW4yfzqzIPLxe4GbIcEPinkywr7InwivyDIsPUYbXE9KBEw==' environment: 'staging'
- name: configure git
run: git config --global user.email "gitea-bot@nanobyte.cz" && git config --global user.name "Gitea Bot"
- name: Install kustomize
run: |
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.3.0/kustomize_v5.3.0_linux_amd64.tar.gz -o kustomize.tar.gz && tar -xzf kustomize.tar.gz
- name: Update images
run: |
cd vlach_xyz_deploy && cd kubernetes/staging/ && ../../../kustomize edit set image pdf=git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_pdf:${{steps.git.outputs.short_hash}} && git add . && git commit -m "upgrade ovlach_pdf -> ${{steps.git.outputs.short_hash}}" && git push origin master

View File

@ -4,59 +4,13 @@ on:
push: push:
branches: branches:
- '*' - '*'
- '!master'
jobs: jobs:
clippy: tests:
runs-on: ubuntu-latest name: tests
container:
image: git.nanobyte.cz/nanobyte-public/nano-rust-builder:1.74.5f84654
steps:
- uses: https://github.com/actions/checkout.git@v4
- name: Hash of Cargo.lock
id: get-hash
run: echo "::set-output name=hash::$(md5sum Cargo.lock | awk '{ print $1; }')"
- uses: https://gitea.com/wolfogre/cache/restore@v3
id: cache
with:
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}"
path: |
.cache
target
restore-keys: ${{github.repository}}-cache-cargo-clippy-v4
- uses: nanobyte-public/rust-action@master
with:
args: CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo clippy -- -Dwarnings
- uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
.cache
target
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}"
test:
container:
image: git.nanobyte.cz/nanobyte-public/nano-rust-builder:1.74.5f84654
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: https://github.com/actions/checkout.git@v4 - uses: actions/rust-test@v1
- name: Hash of Cargo.lock
id: get-hash
run: echo "::set-output name=hash::$(md5sum Cargo.lock | awk '{ print $1; '})"
- uses: https://gitea.com/wolfogre/cache/restore@v3
id: cache
with: with:
path: | repository: ${{github.repository}}
.cache cargo_nan_secret: ${{secrets.deployment_package}}
target
key: "${{github.repository}}-cache-test-clippy-v4-${{ steps.get-hash.outputs.hash }}"
restore-keys: ${{github.repository}}-cache-test-test-v4
- uses: nanobyte-public/rust-action@master
with:
args: |
CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo test
- uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
.cache
target
key: "${{github.repository}}-cache-test-clippy-v4-${{ steps.get-hash.outputs.hash }}"