Skip to content
Open
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
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,27 @@ jobs:
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
credentials_json: ${{ secrets.GCS_DOWNLOADS_SERVICE_ACCOUNT_JSON }}

- name: Google Cloud Setup
if: ${{ github.event_name=='push' }}
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}

- name: Generate checksums for compiled packages
if: ${{ github.event_name=='push' }}
run: |
find ${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}/openwisp_monitoring -type f -name "*.ipk" -exec sha256sum {} \; > ${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}/openwisp_monitoring/sha256sums.txt

- name: Define Storage Paths
run: |
echo "SRC_URL=${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}/openwisp_monitoring" >> $GITHUB_ENV
echo "DST_URL=gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-monitoring/${{ env.START_TIME }}-${{ env.COMMIT_SHA }}" >> $GITHUB_ENV
echo "LATEST_URL=gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-monitoring/latest" >> $GITHUB_ENV
Comment on lines +114 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change was required? We are already defining env in the next command where they are needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to answer you so late ,i have reason besides that
the reason for defining the env variable "Define Storage Paths" is for readability ,reuse because the paths are bit long and used in many commands i think it will be simple for maintainability

i edited the file while learning yaml so i searched and found out that adding the env variable can be good for reuse
if these change are bad then i would remove them and edit the file .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been good if these env variables were used anywhere else. These variables are specific for Google Cloud only and therefore added there.

I don't think moving them upwards solves any for our use case.


- name: Upload compiled packages to downloads.openwisp.io
if: ${{ github.event_name=='push' }}
run: |
gsutil -m rsync -r ${{ env.SRC_URL }} ${{ env.DST_URL }}
gsutil -m rsync -r -d ${{ env.SRC_URL }} ${{ env.LATEST_URL }}
env:
SRC_URL: ${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}/openwisp_monitoring
DST_URL: gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-monitoring/${{ env.START_TIME }}-${{ env.COMMIT_SHA }}
LATEST_URL: gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-monitoring/latest
gsutil -m rsync -r $SRC_URL $DST_URL
gsutil -m rsync -r -d $SRC_URL $LATEST_URL
gsutil cp $SRC_URL/sha256sums.txt $DST_URL/
gsutil cp $SRC_URL/sha256sums.txt $LATEST_URL/
Comment on lines +123 to +126
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are already syncing the source with destination, then why we need to add checksum files ourselves? Shouldn't they will be added automatically in the bucket if they are available?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the safety reason if anything happens than the verification can be smoothly done by checksum file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that in any case the packages are not uploaded online, then we can check it via Checksum? I am not very much convinced.

What do you think @nemesifier ?

Loading