Skip to content

Improve cd action #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,42 @@ jobs:
with:
name: ${{ env.PROJECT_NAME }}
template: template
arguments: "--template-values-file .github/workflows/template_values.toml --verbose"
arguments: "--template-values-file .github/workflows/template_values.toml -d gh-username=${{ github.repository_owner }} --verbose"

- name: Generate lockfile
run: |
cd $PROJECT_NAME
cargo generate-lockfile

- name: Check for references
run: |
if git ls-remote --exit-code [email protected]:${{ github.repository_owner }}/${{ env.PROJECT_NAME }}.git; then
echo "References found in the remote repo"
else
echo "No references found in the remote repo"
mkdir tmp && cd tmp
git config user.name github-actions
git config user.email [email protected]
git init
git branch -M main
git remote add origin [email protected]:PythonGermany/rust-gh-example.git
git commit --allow-empty -m "Initial commit"
git push -u origin main
rm -rf tmp
fi

- name: Checkout old example
uses: actions/checkout@v4
with:
repository: rust-github/rust-gh-example
path: old_example
repository: ${{ github.repository_owner }}/${{ env.PROJECT_NAME }}
path: ${{ env.PROJECT_NAME }}.old
ssh-key: ${{ secrets.GH_EXAMPLE_DEPLOY_SECRET }}

- name: move sources, mit license and Cargo.toml from old to new example
run: |
echo "pwd:"
pwd
echo "ls -al:"
ls -al
rm rust-gh-example/src/main.rs
rm rust-gh-example/Cargo.toml
rm rust-gh-example/LICENSE-MIT
cp old_example/src/* rust-gh-example/src/
cp old_example/Cargo.toml rust-gh-example/Cargo.toml
cp old_example/LICENSE-MIT rust-gh-example/LICENSE-MIT
- name: update example
run: |
mkdir old_sources
mv old_example/src/* old_sources
cd old_example
rm -rf * .gitignore .github/
echo "ls ../rust-gh-example:"
ls ../rust-gh-example
echo "ls ../rust-gh-example/src:"
ls ../rust-gh-example/src
mv ../rust-gh-example/* ../rust-gh-example/.github ../rust-gh-example/.gitignore .
echo "ls -al:"
ls -al
rm src/*
mv ../old_sources/* src
run: cp -rf ${{ env.PROJECT_NAME }}.old/.git ${{ env.PROJECT_NAME }}
- name: commit example
run: |
cd old_example
cd ${{ env.PROJECT_NAME }}
git config user.name github-actions
git config user.email [email protected]
git add .
Expand Down