Created
August 19, 2019 07:22
-
-
Save jonico/e18127b487d198606e31aac669262af8 to your computer and use it in GitHub Desktop.
Build docker image and push to GPR with GitHub Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Jekyll Docker image for Octocat Generator | |
on: [push] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: clean up, docker login && docker build && docker push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GPR_PAT: ${{ secrets.GPR_PAT }} | |
run: | | |
./cleanup.sh | |
docker login -u ${GITHUB_ACTOR} -p ${GPR_PAT} docker.pkg.github.com | |
docker build -t docker.pkg.github.com/${GITHUB_REPOSITORY}/octocat-generator:v-${GITHUB_SHA} . | |
curl -s -H "Authorization: Token ${GITHUB_TOKEN}" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{ \"ref\": \"refs/tags/v-${GITHUB_SHA}\", \"sha\": \"${GITHUB_SHA}\"}" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs | |
docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/octocat-generator:v-${GITHUB_SHA} |
And that curl
line is about creating a tag?
What do you need
${GPR_PAT}
for?
GITHUB_TOKEN, at least when I wrote this snippet, did not have the scope to publish a docker image
And that
curl
line is about creating a tag?
Yes, to associate the created docker image with a specific tag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you need
${GPR_PAT}
for?