Test workflow (v26)

This commit is contained in:
Tom Hubrecht 2023-06-30 11:06:21 +02:00
parent 3dfc666f7c
commit d1961ff465

View file

@ -20,24 +20,60 @@ jobs:
# Hack to set the cache in the working directory # Hack to set the cache in the working directory
HOME="$GITHUB_WORKSPACE" nix-build dgnum.eu HOME="$GITHUB_WORKSPACE" nix-build dgnum.eu
- name: Clone dgnum.eu pages # - name: Clone dgnum.eu pages
run: | # run: |
git clone https://codeberg.org/DGNum/pages # git clone https://codeberg.org/DGNum/pages
#
- name: Update assets
run: |
cp -R --no-preserve=mode,ownership,timestamps result/* pages/
- name: Push new website - name: Push new website
id: push_directory run: |
uses: https://github.com/cpina/github-action-push-to-another-repository@main HOME="$GITHUB_WORKSPACE"
echo "[+] Using SSH_DEPLOY_KEY"
# Setup deploy key
DEPLOY_KEY_FILE="$HOME/.ssh/deploy_key"
mkdir .ssh
echo "${SSH_DEPLOY_KEY}" > "$DEPLOY_KEY_FILE"
chmod 600 "$DEPLOY_KEY_FILE"
# Setup known hosts
KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts"
ssh-keyscan -H codeberg.org > "$KNOWN_HOSTS_FILE"
export GIT_SSH_COMMAND="ssh -i $DEPLOY_KEY_FILE -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE"
GIT_CMD_REPOSITORY="git@codeberg.org:DGNum/$GIT_REPOSITORY.git"
echo "[+] Cloning remote repository"
git clone --single-branch --depth 1 --branch main "$GIT_CMD_REPOSITORY" "$GIT_REPOSITORY"
git config --global user.email "$GIT_USER_EMAIL"
git config --global user.name "$GIT_USER_NAME"
echo "[+] Updating assets"
rm -r "$GIT_REPOSITORY/*"
# Update assets
cp -R --no-preserve=mode,ownership,timestamps result/* "$GIT_REPOSITORY/"
cd "$GIT_REPOSITORY"
echo "[+] Creating commit"
ORIGIN_COMMIT="https://$GIT_ORIGIN_SERVER/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git add .
git diff-index --quiet HEAD || git commit --message "Automatic pages update"
echo "[+] Pushing update"
git push "$GIT_CMD_REPOSITORY" --set-upstream main
env: env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with: GIT_REPOSITORY: pages-test
github-server: codeberg.org GIT_USER_EMAIL: automated-update@dgnum.eu
source-directory: pages/ GIT_USER_NAME: Forgejo Action
destination-github-username: 'DGNum' GIT_ORIGIN_SERVER: git.hubrecht.ovh
destination-repository-name: 'pages-test' # with:
user-email: tom.hubrecht@dgnum.eu # github-server: codeberg.org
commit-message: See ORIGIN_COMMIT from $GITHUB_REF # source-directory: pages/
target-branch: main # destination-github-username: 'DGNum'
# destination-repository-name: 'pages-test'
# user-email: tom.hubrecht@dgnum.eu
# commit-message: See ORIGIN_COMMIT from $GITHUB_REF
# target-branch: main