Skip to content
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

Getting the github Repo from env #1532

Merged
merged 10 commits into from
Sep 13, 2023

Conversation

pushyamig
Copy link
Contributor

@pushyamig pushyamig commented Aug 25, 2023

Fixes #1533

The changes made check out the repo does and build and pushes to forked repo packages instead of TL Myla repo

@pushyamig pushyamig requested a review from jonespm August 25, 2023 20:26
@pushyamig
Copy link
Contributor Author

pushyamig commented Aug 25, 2023

How to test this: We want to make sure this works for all forked branches

  1. Pull this repo to locally and give a name as you prefer
  2. Commit this branch as you local branch to your Myla fork
  3. make changes to the branch from master to <what_ever_you_named_it>
  4. This lastest commit should trigger a GH actions build workflow
  5. The Build should be successful and see a nice image create from the packages tab


- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=$(basename ${{ github.ref }})" >> $GITHUB_ENV
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the step the pull the branch it is built from.

Copy link
Contributor Author

@pushyamig pushyamig Aug 25, 2023

Choose a reason for hiding this comment

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

There was an env variable called github.base_ref but some reason it did not work. So I have to adopt this workaround for pulling the branch name

- name: build Docker image
run: |
docker build . --tag ghcr.io/${{ env.REPO_URL }}:${{ env.IMAGE_TAG }}-${BRANCH_NAME}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tag will like latest-master or latest-2020-01.01

Copy link
Member

Choose a reason for hiding this comment

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

Interesting so it auto builds the tags too. That seems convenient. I think the name is fine with the latest in it.

jobs:
build:
# to test a feature, change the repo name to your github id
if: github.repository_owner == 'tl-its-umich-edu'
Copy link
Contributor Author

@pushyamig pushyamig Aug 28, 2023

Choose a reason for hiding this comment

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

This way we could stop the build for forked branches. I see an action recorded momentarily and it skips https://github.com/pushyamig/my-learning-analytics/actions/runs/6000238741. @jonespm Thanks for suggestion.

The better way if we want to skip it completely, than we need to create github PAT https://github.com/peter-evans/repository-dispatch. I think i will skip that far at the moment

Copy link
Member

Choose a reason for hiding this comment

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

I think this is good for now.

@pushyamig
Copy link
Contributor Author

@jonespm this is ready for review

@pushyamig
Copy link
Contributor Author

@jonespm This needs a review

# takes muliple branch names
branches:
- master
- '[0-9][0-9][0-9][0-9].[0-9][0-9].*' # 2021.01.01
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will support build of MyLA release branch if there is commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Github Packages outcomes

The tagging is like latest-2023.09.x

Copy link
Member

@jonespm jonespm left a comment

Choose a reason for hiding this comment

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

I think this looks good. We'll have to try it out to see how it works with the whole process but I don't have anything I'd change here yet.

@pushyamig pushyamig merged commit c156cf8 into tl-its-umich-edu:master Sep 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For Github actions/registry get the Repo values from environment
2 participants