Skip to content

synchronize source code with Artifactory #1

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

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
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
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# action-src-mirror
Synchronize files between repository and Artifactory
Checkout, pack, and upload source code to Artifactory


Example:

```
- name: Sync source to Artifactory
uses: nrfconnect/action-src-mirror@main
with:
git-ref: ${{ github.ref_name }}
git-fetch-depth: '0'
path: 'workspace/nrf'
west-update-args: '--group-filter=+babblesim'
artifactory-url: 'https://eu.files.nordicsemi.com/artifactory'
artifactory-repository: 'ncs-src-mirror'
artifactory-target-prefix: 'external'
artifactory-user: ${{ secrets.COM_NORDICSEMI_FILES_USERNAME }}
artifactory-pass: ${{ secrets.COM_NORDICSEMI_FILES_PASSWORD }}
```
92 changes: 92 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Synchronize Source'
description: 'Checkout, pack, and upload source code to Artifactory'
inputs:
git-ref:
description: 'Branch, tag or SHA to checkout'
required: true
git-fetch-depth:
description: 'Git fetch depth (0 = full history, 1 = shallow)'
required: false
default: '0'
path:
description: 'Directory to checkout sources into'
required: false
default: ''
west-update-args:
description: 'Arguments to pass to `west update`'
required: false
default: ''
artifactory-url:
description: 'Base URL of Artifactory'
required: false
default: 'https://eu.files.nordicsemi.com/artifactory'
artifactory-repository:
description: 'Artifactory repository name'
required: false
default: 'ncs-src-mirror'
artifactory-target-prefix:
description: 'Prefix path in Artifactory (e.g., external)'
required: true
default: ''
artifactory-target-file-name:
description: 'Source file name in Artifactory '
required: false
artifactory-user:
description: 'Artifactory username (pass as workflow secret)'
required: true
artifactory-pass:
description: 'Artifactory password or API key (pass as workflow secret)'
required: true

runs:
using: composite
steps:
- name: Checkout sources
uses: nrfconnect/action-checkout-west-update@main
with:
git-ref: ${{ inputs.git-ref }}
git-fetch-depth: ${{ inputs.git-fetch-depth }}
path: workspace/${{ inputs.path }}
west-update-args: ${{ inputs.west-update-args }}


- name: Configure git and run garbage collection
shell: bash
run: |
cd "workspace/${{ inputs.path }}"
git config --global pack.windowMemory "32m"
west forall -c 'git gc --prune --aggressive'

- name: Create tar archive
shell: bash
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
TAG="${GITHUB_REF_NAME}"
FILE_NAME="${REPO_NAME}-${TAG}.tar.gz"
tar -C "workspace" -czvf "${FILE_NAME}" .

- name: Set up JFrog CLI
uses: jfrog/setup-jfrog-cli@v4

- name: Upload to Artifactory
shell: bash
env:
ARTIFACTORY_URL: ${{ inputs.artifactory-url }}
REPOSITORY: ${{ inputs.artifactory-repository }}
TARGET_PREFIX: ${{ inputs.artifactory-target-prefix }}
USER: ${{ inputs.artifactory-user }}
PASS: ${{ inputs.artifactory-pass }}
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
TAG="${GITHUB_REF_NAME}"
FILE_NAME="${REPO_NAME}-${TAG}.tar.gz"
TARGET_DIR="${REPOSITORY}/${TARGET_PREFIX}/${TAG}/"
if [ -n "${{ inputs.artifactory-target-file-name }}" ]; then
UPLOAD_NAME="${{ inputs.artifactory-target-file-name }}"
else
UPLOAD_NAME="${FILE_NAME}"
fi
jfrog rt u "${FILE_NAME}" "${TARGET_DIR}${UPLOAD_NAME}" \
--url="${ARTIFACTORY_URL}" \
--user="${USER}" \
--password="${PASS}"