Skip to content

Commit 2b8d2ee

Browse files
committed
initial commit
0 parents  commit 2b8d2ee

12 files changed

+738
-0
lines changed

Diff for: .github/workflows/main-s3.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
3+
# Copyright 2023 Skyscanner Limited.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Tests for S3 Reusable Workflow
18+
name: Main S3
19+
20+
on:
21+
# Triggers the workflow on push or pull request events but only for the "main" branch
22+
push:
23+
branches: [ "main" ]
24+
paths:
25+
- '.github/workflows/reusable-s3.yaml'
26+
- '.github/workflows/main-s3.yaml'
27+
pull_request:
28+
branches: [ "main" ]
29+
paths:
30+
- '.github/workflows/reusable-s3.yaml'
31+
- '.github/workflows/main-s3.yaml'
32+
33+
# Allows you to run this workflow manually from the Actions tab
34+
workflow_dispatch:
35+
36+
permissions:
37+
contents: read
38+
id-token: write
39+
40+
jobs:
41+
build:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Make a file to upload
45+
run: |
46+
mkdir static
47+
echo "i am a test file" > static/test.txt
48+
- name: Put content into build time artifact
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: static-content
52+
path: static
53+
54+
reusable-s3-dry-run:
55+
uses: ./.github/workflows/reusable-s3.yaml
56+
needs: build
57+
with:
58+
dry-run: true
59+
60+
reusable-s3:
61+
uses: ./.github/workflows/reusable-s3.yaml
62+
needs:
63+
- build
64+
- reusable-s3-dry-run

Diff for: .github/workflows/reusable-s3.yaml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
3+
# Copyright 2023 Skyscanner Limited.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Reusable Workflow for S3 uploads
18+
name: Upload to S3
19+
20+
on:
21+
workflow_call:
22+
inputs:
23+
dry-run:
24+
required: false
25+
type: boolean
26+
description: Displays the operations that would be performed without actually running them.
27+
default: false
28+
artifact-name:
29+
required: false
30+
type: string
31+
description: Name of the artifact to upload.
32+
default: static-content
33+
34+
permissions:
35+
contents: read
36+
id-token: write
37+
38+
env:
39+
BUCKET: 'x'
40+
ROLE_TO_ASSUME: 'arn:aws:iam::####:role/X'
41+
REGION: 'x-x-#'
42+
43+
jobs:
44+
bucket-upload:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/github-script@v6
48+
id: prepare-aws-role-session-name
49+
with:
50+
# https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html
51+
# RoleSessionName only permits [\w+=,.@-]*
52+
script: return "GitHubActions," + context.repo.owner + "@" + context.repo.repo
53+
result-encoding: string
54+
55+
- name: Login AWS
56+
uses: aws-actions/[email protected]
57+
with:
58+
role-to-assume: ${{ env.ROLE_TO_ASSUME }}
59+
role-session-name: ${{ steps.prepare-aws-role-session-name.outputs.result }}
60+
aws-region: ${{ env.REGION }}
61+
mask-aws-account-id: 'no'
62+
inline-session-policy: >-
63+
{
64+
"Version": "2012-10-17",
65+
"Statement": [
66+
{
67+
"Effect": "Allow",
68+
"Action": [
69+
"s3:ListBucket"
70+
],
71+
"Resource": [
72+
"arn:aws:s3:::${{ env.BUCKET }}"
73+
]
74+
},
75+
{
76+
"Effect": "Allow",
77+
"Action": [
78+
"s3:GetObject",
79+
"s3:GetObjectAcl",
80+
"s3:GetObjectVersion",
81+
"s3:PutObject",
82+
"s3:PutObjectAcl"
83+
],
84+
"Resource": [
85+
"arn:aws:s3:::${{ env.BUCKET }}/${{ github.repository }}/*"
86+
]
87+
}
88+
]
89+
}
90+
91+
92+
- name: "Debug: sts get-caller-identity"
93+
run: |
94+
aws sts get-caller-identity --output table --color on
95+
96+
- name: Download artifact
97+
uses: actions/download-artifact@v3
98+
with:
99+
name: ${{ inputs.artifact-name }}
100+
path: /tmp/bucket-upload/
101+
102+
- name: List content to be uploaded
103+
run: ls /tmp/bucket-upload/
104+
105+
- name: Upload to S3 bucket
106+
run: |
107+
aws s3 cp ${{ inputs.dry-run && '--dryrun' || '' }} --recursive /tmp/bucket-upload/ s3://${{ env.BUCKET }}/${{ github.repository }}

Diff for: CODE_OF_CONDUCT.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behaviour that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behaviour by participants include:
24+
25+
* The use of sexualized language or imagery and sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behaviour and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behaviour.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviours that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behaviour may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

Diff for: CONTRIBUTING.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing to gha-aws-oidc-sample
2+
3+
We're glad you want to make a contribution!
4+
5+
Fork this repository and send in a pull request when you're finished with your changes. Link any relevant issues in too.
6+
7+
Take note of the build status of your pull request, only builds that pass will be accepted. Please also keep to our conventions and style so we can keep this repository as clean as possible.
8+
9+
## License
10+
11+
By contributing your code, you agree to license your contribution under the terms of the APLv2: [LICENSE](LICENSE)
12+
13+
All files are released with the Apache 2.0 license.
14+
15+
If you are adding a new file it should have a header like this:
16+
17+
```
18+
/**
19+
* Copyright <<YEAR>> Skyscanner Limited.
20+
*
21+
* Licensed under the Apache License, Version 2.0 (the "License");
22+
* you may not use this file except in compliance with the License.
23+
* You may obtain a copy of the License at
24+
*
25+
* http://www.apache.org/licenses/LICENSE-2.0
26+
*
27+
* Unless required by applicable law or agreed to in writing, software
28+
* distributed under the License is distributed on an "AS IS" BASIS,
29+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30+
* See the License for the specific language governing permissions and
31+
* limitations under the License.
32+
*/
33+
```

0 commit comments

Comments
 (0)