Skip to content

Commit

Permalink
ci: PLT-409: Skip Docker image push for external contributors (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabelonogov authored Jul 8, 2024
1 parent 710f1a6 commit f7b9f36
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ jobs:
steps:
- uses: hmarr/[email protected]

- name: Check user's membership
uses: actions/github-script@v7
id: check-membership
env:
ACTOR: ${{ github.actor }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const actor = process.env.ACTOR;
const { data: membership } = await github.rest.orgs.getMembershipForUser({
org: owner,
username: actor,
});
if (membership.state != "active") {
const error = `Unfortunately you don't have membership in ${owner} organization`;
core.setOutput("error", error);
core.setFailed(error);
}
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -86,7 +106,7 @@ jobs:
with:
context: .
file: Dockerfile.app
push: true
push: ${{ steps.check-membership.outputs.error && true || false }}
tags: ${{ steps.calculate-docker-tags.outputs.docker-tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down

0 comments on commit f7b9f36

Please sign in to comment.