Skip to content

Commit

Permalink
Fix issues with translation deployment script
Browse files Browse the repository at this point in the history
During the 0.25.1/0.44.1 release the translation publishing step failed.
This was because of a parsing error with the ssh private key during the
decryption step. This seems to be due to how the action was configured
to load the private key post decryption into an env variable that github
actions would then use for it's checkout action to handle cloning with
authentication via ssh. This commit switches back to just using a
standalone bash script that has proven to be reliable historically and
also gives us tighter control on how commands get executed. As part of
this a new encrypted private key is added to the repo as the previous
key has been revoked and invalidated since the job failure during the
release.
  • Loading branch information
mtreinish committed Aug 18, 2023
1 parent 7bc2bfd commit 6446ed5
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 43 deletions.
46 changes: 3 additions & 43 deletions .github/workflows/docs_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,47 +222,7 @@ jobs:

- name: Decrypt SSH secret key
id: ssh_key
run: |
set -e
ssh_key=$(openssl enc -aes-256-cbc -d -in qiskit/tools/github_poBranch_update_key.enc -K $SSH_UPDATE_KEY -iv $SSH_UPDATE_IV)
echo "::add-mask::${ssh_key}"
echo "ssh_key=${ssh_key}" >> "$GITHUB_OUTPUT"
run: tools/deploy_translatable_strings.sh
env:
SSH_UPDATE_KEY: ${{ secrets.ENCRYPTED_DEPLOY_PO_BRANCH_KEY }}
SSH_UPDATE_IV: ${{ secrets.ENCRYPTED_DEPLOY_PO_BRANCH_IV }}

- uses: actions/checkout@v3
with:
repository: 'qiskit-community/qiskit-translations'
path: 'qiskit-translations'
ssh-key: '${{ steps.ssh_key.outputs.ssh_key }}'

- name: Remove ignored documents
run: rm -r LC_MESSAGES/{apidocs,stubs}
working-directory: 'deploy'

- name: Push changes to translations repository
run: |
set -e
shopt -s failglob
# Bring the new `.po` target files into the repository.
git rm -r --ignore-unmatch docs/locale/en
mv "${{ github.workspace }}/deploy" docs/locale/en
# Update the ways to recreate the build.
cp "${{ github.workspace }}/qiskit/"{setup.py,requirements-*.txt,constraints.txt} .
git add .
cat > COMMIT_MSG << EOF
Automated documentation update to add .po files from ${{ github.repository }}
skip ci
Commit: ${{ github.sha }}
GitHub Actions run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
git config user.name "Qiskit Autodeploy"
git config user.email "qiskit@qiskit.org"
git commit -F COMMIT_MSG
git push origin
working-directory: 'qiskit-translations'
encrypted_deploy_po_branch_key: ${{ secrets.ENCRYPTED_DEPLOY_PO_BRANCH_KEY }}
encrypted_deploy_po_branch_iv: ${{ secrets.ENCRYPTED_DEPLOY_PO_BRANCH_IV }}
87 changes: 87 additions & 0 deletions tools/deploy_translatable_strings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# Script for pushing the translatable messages to poBranch.


# Variables used by this script.
# From github actions the docs/locale/en directory from the sphinx build
# gets downloaded from the github actions artifacts as deploy directory
TARGET_REPOSITORY="git@github.com:qiskit-community/qiskit-translations.git"
SOURCE_DIR=`pwd`
SOURCE_LANG='en'

SOURCE_REPOSITORY="git@github.com:Qiskit/qiskit.git"
TARGET_BRANCH_PO="master"
DOC_DIR_PO="deploy"
TARGET_DOCS_DIR_PO="docs/locale"

echo "show current dir: "
pwd

echo "Setup ssh keys"
pwd
set -e
# Add poBranch push key to ssh-agent
openssl enc -aes-256-cbc -d -in ../tools/github_poBranch_update_key.enc -out github_poBranch_deploy_key -K $encrypted_deploy_po_branch_key -iv $encrypted_deploy_po_branch_iv
chmod 600 github_poBranch_deploy_key
eval $(ssh-agent -s)
ssh-add github_poBranch_deploy_key

# Clone to the working repository for .po and pot files
popd
pwd
echo "git clone for working repo"
git clone --depth 1 $TARGET_REPOSITORY temp --single-branch --branch $TARGET_BRANCH_PO
pushd temp

git config user.name "Qiskit Autodeploy"
git config user.email "qiskit@qiskit.org"

echo "git rm -rf for the translation po files"
git rm -rf --ignore-unmatch $TARGET_DOC_DIR_PO/$SOURCE_LANG/LC_MESSAGES/*.po \
$TARGET_DOCS_DIR_PO/$SOURCE_LANG/LC_MESSAGES/api \
$TARGET_DOCS_DIR_PO/$SOURCE_LANG/LC_MESSAGES/apidoc \
$TARGET_DOCS_DIR_PO/$SOURCE_LANG/LC_MESSAGES/apidoc_legacy \
$TARGET_DOCS_DIR_PO/$SOURCE_LANG/LC_MESSAGES/theme \
$TARGET_DOCS_DIR_PO/$SOURCE_LANG/LC_MESSAGES/_*

# Remove api/ and apidoc/ to avoid confusion while translating
rm -rf $SOURCE_DIR/$DOC_DIR_PO/LC_MESSAGES/api/ \
$SOURCE_DIR/$DOC_DIR_PO/LC_MESSAGES/apidoc/ \
$SOURCE_DIR/$DOC_DIR_PO/LC_MESSAGES/apidoc_legacy/ \
$SOURCE_DIR/$DOC_DIR_PO/LC_MESSAGES/stubs/ \
$SOURCE_DIR/$DOC_DIR_PO/LC_MESSAGES/theme/

# Copy the new rendered files and add them to the commit.
echo "copy directory"
cp -r $SOURCE_DIR/$DOC_DIR_PO/. $TARGET_DOCS_DIR_PO/$SOURCE_LANG
cp $SOURCE_DIR/qiskit_pkg/setup.py .
cp $SOURCE_DIR/requirements-dev.txt .
# Append optional requirements to the dev list as some are needed for
# docs builds
cat $SOURCE_DIR/requirements-optionals.txt >> requirements-dev.txt
cp $SOURCE_DIR/constraints.txt .

echo "add to po files to target dir"
git add docs/
git add setup.py
git add requirements-dev.txt constraints.txt

# Commit and push the changes.
git commit -m "Automated documentation update to add .po files from meta-qiskit" -m "skip ci" -m "Commit: $GITHUB_SHA" -m "Github Actions Run: https://github.com/Qiskit/qiskit/runs/$GITHUB_RUN_NUMBER"
echo "git push"
git push --quiet origin $TARGET_BRANCH_PO
echo "********** End of pushing po to working repo! *************"
popd
Binary file modified tools/github_poBranch_update_key.enc
Binary file not shown.

0 comments on commit 6446ed5

Please sign in to comment.